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;
}
1
Expert's answer
2014-09-24T12:22:06-0400
#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!!!"; _getch(); return 0; }
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:
https://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
Thank you! Your comments have been successfully added. However, they need to be checked by the moderator before being published.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
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: https://www.cplusplus.com/reference/string/string/getline/?kw=getline
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