simple code wont compile and don't know why

basically I am very new to coding I have been in 3d graphics for a few years and decided that I want to learn programming to aid me. I have purchased c++ for dummies and online training. i started a few tutorials and did them successfully now i want to try and take what i have learned and create my own code. this is what i have so far.

#include<iostream>
using namespace std

int main(void)
{
int NumberX = 0
int NumberY = 0
int Numberz = 0
int FinalNumber = 0

cout <<"please enter 3 numbers: " << endl;
cin >> NumberX;
cin >> NumberY;
cin >> NumberZ;

FinalNumber = NumberX + NumberY - NumberZ;

cout <<" all my hard work finally: " << FinalNumber << endl;

system ("pause");
return 0;
}


as you have guessed it doesn't work and I am frustrated and don't know what i did wrong.
I think it is because you are missing semicolons after your int declarations and also after using namespace std. Maybe there should be a space between #include and <iostream> as well. Also, I don't know what int main(void) is but int main() should be enough for this program.
Last edited on
ok thanks for the help workign on it now hopefully I can get this fiquired out. It seems to be better since i am using int main() this is what I have so far. as you can guess i really don't understadn what I am doing. but right now it makes it all the way to ( cout <<"please enter 3 numbers:";

#include<iostream>
using namespace std;

int main()
{
int NumberX;
int NumberY;
int Numberz;
int FinalNumber = 0

cout <<"please enter 3 numbers:";
cin >> NumberX;
cin >> NumberY;
cin >> NumberZ;

FinalNumber = NumberX + NumberY - NumberZ;

cout <<" all my hard work finally: " << FinalNumber << endl;

system ("pause");
return 0;
}
Last edited on
You left out a semicolon after int FinalNumber = 0. These semicolons are extremely important! I think you need to figure out what needs a semicolon and a bit of practice. As for your code, it is nice and logical.
Hope that helps
Last edited on
I feel really stupid, I have been staring at this for about an hour. Sorry for wasting your time. I thought I looked over and had every semi colon. it works now and i do thank you for all your help.

also could you please explain just one thing. I'm new to this and the material I have don't do a good job covering
int main()

basically they sad it is at the start at every program and thus you need to enter it in but they did not go into much detail.
@wind27382:
Also, try to get used to using any alternatives to system() commands. Instead of system("pause") you can use cin.get() or something else.
I can't fully explain main() to you, but It is your program's main function. As for your program, once main is done running, it will return a 0. I'm fairly new to C++ myself, but I think you will understand more once you get into using functions.

Also, I think a main() with argument(s) such as argc or argv inside are commonly used for command line programming in Unix.

I hope that helps a tiny bit.
thank you guys i have much to learn but thanks for the help. I'll also look into alternatives for system commands.
Topic archived. No new replies allowed.