First, please use the code tags (it's the <> button under Format to the right when posting or editing) to post code. It makes it a lot easier to read and even adds line numbers.
First, when you cout sum you've already assigned the value of a+b+c to sum, so you can just output sum itself.
Second, you forgot the semi-colon after the system("pause"); and also forgot to include the <cstdlib> of which system is a part of.
Also, using system statements like this is kind of bad form and not recommended. A better line of code to pause the program so you can see the window is
cin.get()
This will wait until you hit enter before closing the window.
One last thing. Your average won't be quite as precise as it could be since you are using an int variable. That's prolly ok since this isn't a large program that really needs the precision of a float or a double.
#include <iostream>
#include <windows.h>
usingnamespace std;
int a, b, c, sum, avg;
int main()
{
cout << "Enter your marks: ";
cin >> a >> b >> c;
sum = a + b + c;
cout << "- Sum: " << sum << endl;
avg = sum / 3;
cout << "- AVG: "<< avg << endl;
system("PAUSE");
return 0;
}
You can do this too for optimize your code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <windows.h>
usingnamespace std;
int a, b, c;
int main()
{
cout << "Enter your marks: ";
cin >> a >> b >> c;
cout << "- Sum: " << a + b + c << endl;
cout << "- AVG: "<< (a + b + c) / 3 << endl;
system("PAUSE");
return 0;
}
Take the example of Bartek as a good one.
But, when you will be developing a serious program, don't use system(). It marks you as a bad programmer and your program will be marked as a virus by most antiviruses out there.
AVG did to me once. I mean, ONCE. Then I uninstalled it, lol.