im having challenge with this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

im having challenge with this code

#include <iostream> using namespace std; int main() { char Fname,Lname,email,address,contact; cout << "Enter your First name "; cin>>Fname; cout << "Enter your Last name "; cin>>Lname; cout << "Enter your email "; cin>>email; cout << "Enter your address "; cin>>address; cout << "Enter your contact "; cin>>contact; cout << "Your full name is "<<Fname<<" "<<Lname<<" with an email address "<<email<<"with address "<<address<<"and your contact number is "<<contact<<endl; return 0; }

20th Mar 2020, 11:11 AM
Bismark Abban
Bismark Abban - avatar
7 Answers
0
what's wrong with the code? i cant see anything wrong about the code so please specify what the problem or challenge is.
20th Mar 2020, 12:13 PM
MMS
MMS - avatar
0
It's fine code but you declared all variables as char only so it accept only single char.. Edit: (use charecter array for taking strings). Ex: For string accept for Fname, use char* Fname or char[] Fname.
20th Mar 2020, 12:21 PM
Jayakrishna 🇮🇳
0
The output "enter your address", enter your contact" shows on the same line.. it doesn't give me the opportunity to input them seperetely
20th Mar 2020, 2:28 PM
Bismark Abban
Bismark Abban - avatar
0
You can use endl or \n to come to new line like cout<<"enter your address\n"; cin>>address; One more point, that cin accept only one word.. It stops reading after space or new line encounters...
20th Mar 2020, 2:33 PM
Jayakrishna 🇮🇳
0
can I use getline for all the input like Fname, Lname, address, and contact
20th Mar 2020, 2:53 PM
Bismark Abban
Bismark Abban - avatar
0
Yes. To take a line of string, use getline. If it single line, cin enough.. You can use it for all but enter input separate lines.. I forget to add it in previous post.
20th Mar 2020, 2:58 PM
Jayakrishna 🇮🇳
0
ok.. its working now. Thank you very much
20th Mar 2020, 8:08 PM
Bismark Abban
Bismark Abban - avatar