Error: expected unqualified-id before...

#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
int guess;

cout<<"type a number greater than 5: "<<
cin << guess;
}
if(guess>5);
{
cout<<"Congrats! You have succeded!!!"<<;
}
else;
{
cout<<"You have failed this simple task."<<;
}
return 0;







I cant seem to figure out what is wrong. I am very new at programming and i am just a little confused. Any help would be nice. The errors are: expected unqualified-id before if, expected unqualified-id before {, expected unqualified-id before else, expected unqualified-id before {, expected unqualified-id before return.
;O Why close main and have the rest of the code outside the scope?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main(int nNumberofArgs, char* pszArgs[])
 {
 int guess;

 cout<<"type a number greater than 5: "<<
 cin << guess;
 
 if(guess>5);
 {
 cout<<"Congrats! You have succeded!!!"<<;
 }
 else;
 {
 cout<<"You have failed this simple task."<<;
 }
 return 0;
}
Last edited on
not trying to sound like a noob but how did i close main? do i need to just say int main()??
closed account (z05DSL3A)
All the code for functions goes in a block. A block of code starts with an open brace '{' and finishes with a closing brace '}'.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    int guess;

    cout<<"type a number greater than 5: "<<
        cin << guess;
}                                               // <---- your main finishes here
if(guess>5);
{
    cout<<"Congrats! You have succeded!!!"<<;
}
else;
{
    cout<<"You have failed this simple task."<<;
}
return 0;


Edit:
This is your code with other errors fixed...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    int guess;

    cout << "type a number greater than 5: ";
    
    cin >> guess;

    if(guess>5)
    {
        cout<<"Congrats! You have succeded!!!";
    }
    else
    {
        cout<<"You have failed this simple task.";
    }
    return 0;
}
Last edited on
OOHHHHHHHHH i see thank you soooo much man!!!!!!!!!!! I got it
Topic archived. No new replies allowed.