-
skipping lines
I just started up on programming in C++ from QBASIC and i was wondering how, when entering text, can u skip lines?
When I put this in:
Code:
#include <iostream>
using namespace std;
int main()
{
int num;
int num2;
cout<<"Hello There!";
cout<<"What is your favorite number?";
cin>>num;
cout<<"Your favorite number is: "<<num;
return 0;
}
It come out to:
"Hello There!Whats your favorite number?"
And I want it tho show:
"Hellow There!"
"Whats your favorite number?"
Yeah im a newbie but ne help would be great!
-
Simple problem:
Code:
...
cout<<"Some text..."<<std::endl; /*or just endl if you already have using namespace std at the top of your program*/
cout<<"Some text on the next line\n";
cout<<"\\n creates a new line as well!";
Basically, you just need to add \n to the end of your text (within the quotes) or you can use endl, which also flushes the output buffer.
-
You could do:
cout<<"Hello There!" << endl;
That will put a newline after the preceding
OR:
cout<<"Hello There!";
cout<<"\nWhat is your favorite number?";
Anywayzzz, FYI that was basic c++ that you should learn from available tutorial on this site.