First, you should start with:
#include <iostream>
Should be the first thing you type when writing a program.
Then:
using namespace std;
Include a semicolon after every statement ";".
Now, when you're actually going to start writing what the program does, you need an int main().
1 2 3 4
|
#include <iostream>
using namespace std;
int main(){
|
Next, declare your variables.
int a, b, c, d, e, f, g, h, i;
When declaring them, int is used for whole numbers, while double is used for whole numbers and decimals.
More stuff:
cout << "Please input 9 numbers, separated by spaces." << '\n';
"cout << " Tells the comp to say something to the user.
with cout << , use "" to tell the machine to say whatever's between the quotes. For example:
cout << "thereisnospoon";
"cin >> " takes the user's input and saves them to variables.
'\n' and endl start new lines.
>> is used to input
<< is used to output
1 2 3 4
|
cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
cout << a << ", " << b << ", " << c << ", " << '\n';
cout << d << ", " << e << ", " << f << ", " << '\n';
cout << g << ", " << h << ", " << i;
|
This is how you would output all of those numbers in that format.
EDIT:
Forgot to add,
1 2 3
|
cin.ignore(2);
return 0;
}
|
Make sure to close the brace.
cin.ignore(); so that when you run it, it stays open long enough for you to see what it did.