Compilation problem

Hello, i am very noob at programing and i need help at this code:

1
2
3
4
5
6
7
8
9
10
#include<iostream>
using namespace std;
int main;
{
    int n, a=0, sum;
    do{cin>>n;}while(n<0);
    do{sum=sum+a; a=a+3;}while(a<n);
    cout<<sum;
    system("PAUSE");
    return 0;}

I have two errors at the line four.
4 C:\... expected unqualified-id before '{' token
4 C:\... expected `,' or `;' before '{' token
closed account (28poGNh0)
This is what cause the errorint main; remplace it with
int main()

main is function all functions have parentecies
also to use system("something");
you should include <cstdlib>

however dont use it and use cin.get(); instead
Last edited on
thank you for this.. now i have remembered about it.. but unfortunely it still gives me the same errors..Can you think about something else? Thank you again for the "()"!
closed account (28poGNh0)
can you show us this error ? copy it and paste it here
You are not supposed to have a ; after a function if you are going to define it. Hence:

1
2
3
int main() {
   //stuff
}


Also, please try to use good indentation style, it will make things much clearer and easier to read. For example:

1
2
3
do {
   cin>>n;
} while(n<0);
Now it works... thank you firedraco and techno01 ..
Topic archived. No new replies allowed.