76 297
Assignments Done
Successfully Done
In May 2019

Answer to Question #46705 in C++ for kelvin quist

Question #46705
i wrote this program to ask details of a person but the i am not getting my desired output. my out is all jammed up
how do i fix this
//First program written by Group 1
//This program takes the details of students and submits it

#include <iostream>

using namespace std;

int main ()
int Fullname, Phonenumber, Course, Level, ID;
int submit;
cout << "Welcome to Group 1 Log in Page";
cout <<"Enter your full name";
cin >>Fullname;
cout <<"Enter your phone number";
cin >>Phonenumber;
cout <<"Enter your course";
cin >>Course;
cout <<"Enter your Level";
cin >>Level;
cout <<"Enter your ID";
cin >>ID;
cout <<submit;
cout <<"Thank you for using Group 1's Program. Have a great day!!!";
return 0;
Expert's answer
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int main ()
int Phonenumber, Course, Level, ID;
string Fullname;
cout << "Welcome to Group 1 Log in Page"<<endl;
cout <<"Enter your full name:"<<endl;
getline(cin, Fullname);
cout <<"Enter your phone number:"<<endl;
cin >>Phonenumber;
cout <<"Enter your course:"<<endl;
cin >>Course;
cout <<"Enter your Level:"<<endl;
cin >>Level;
cout <<"Enter your ID:"<<endl;
cin >>ID;
cout << "Excellent! Your info is:"<<endl;
cout<<"Full name : "<< Fullname <<endl;
cout<<"Phone number : "<< Phonenumber <<endl;
cout<<"Course : "<< Course <<endl;
cout<<"Level : "<< Level <<endl;
cout<<"ID : "<< ID <<endl;
cout <<"Thank you for using Group 1's Program. Have a great day!!!";
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


Assignment Expert
26.09.14, 17:00

You're welcome!

getline is used to save a long user input with spaces to the variable "Fullname", because cin separates input stream by spaces. Read more here: http://www.cplusplus.com/reference/string/string/getline/?kw=getline

kelvin quist
26.09.14, 12:01

yh it worked to my desired satisfaction. i am so greatfull and i have realised my mistakes but i cant figure out the use of "getline(cin, Fullname);

thanks once again.

Leave a comment

Ask Your question

Privacy policy Terms and Conditions