-
December 2nd, 2010, 11:42 AM
#1
Very basic help
Code:
#include <iostream>
#include <string>
using namespace std;
string name;
int main()
{
cout << "Hello, Please enter your name\n";
cin >> name;
cout << "Hello ";
cout << name;
system ("PAUSE");
}
So the problem is After "Hello (name)" i cannot make the "Press any key to continue" or whatever, move down a line?
-
December 2nd, 2010, 11:46 AM
#2
Re: Very basic help
The message will appear after all other text on the console. If you want it to appear on a different line, output a newline before calling pause.
-
December 2nd, 2010, 11:49 AM
#3
Re: Very basic help
Originally Posted by Lindley
The message will appear after all other text on the console. If you want it to appear on a different line, output a newline before calling pause.
How do i output a newline?
-
December 2nd, 2010, 11:52 AM
#4
Re: Very basic help
I did this and it works.
Code:
#include <iostream>
#include <string>
using namespace std;
string name;
int main()
{
cout << "Hello, Please enter your name\n";
cin >> name;
cout << "Hello ";
cout << name;
cout << "\n";
system ("PAUSE");
}
-
December 2nd, 2010, 12:02 PM
#5
Re: Very basic help
Code:
#include <iostream>
#include <string>
using namespace std;
string name;
string answer1;
int A;
int B;
int C;
int main()
{
//This is the Users name
cout << "Hello, Please enter your name\n";
cin >> name;
cout << "Hello ";
cout << name;
cout << "\n";
//Quiz starts here below
cout << "Welcome to this Quiz, You will need to answer using\n";
cout << " A,B,C Only, Do not write the actuall answer\n";
system("PAUSE");
system("CLS");
cout << "#1: What year was World War 2 Officially over?\n";
cout << "A: July 4, 1939\n";
cout << "B: September 2, 1945\n";
cout << "C: May 14, 1942\n";
//------- answer below
cin >> answer1;
if (answer1 == B);
cout << "Correct, Well done";
else cout << "Wrong!, The correct answe is B";
}
Con someone help me with this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|