We need to make a program which when run, it will ask for the users Name, Age, Course, Year Lvl, Address, and Gender.
We're using Turbo Cplusplus IDE,
please correct my codes if im wrong, im just a student and a beginner in Cplusplus .
I first try to make an output like this just to test that my program will run,
Name:
Age:
using these codes
#include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
char name[] ={"Name: "};
int age;
cout<< name <<endl;
cin>> name;
cout << "Age: " << age<<endl;
cin>> age;
getch();
}
but when i run it, the output only shows this:
Name:
the "Age: " did not appear,
how can i make the output we need to do, if i cant make the output i want to try first?
Copyright © 2024 QUIZLS.COM - All rights reserved.
Answers & Comments
Verified answer
In your code
you are displaying Name; (cout<< name <<endl; )
after that you are
asking for user input (cin>> name; )
So, when you get "Name:" on the screen, you will have to input something using keyboard and press enter
and then you will get
Age: on the screen- after that you will have to input age using keyboard.
you could do something like this.
-----------------------------------------------------------------------
int main()
{
clrscr();
char name[];
int age;
cout<< "enter Name: ";
cin>> name;
cout << "enter Age: ";
cin>> age;
cout<<"Name is "<<name<<endl;
cout<<"Age is "<<age<<endl;
getch();
}