c++ - "error:expected ';' before '{' token -


i'm doing homework in c++ using code blocks. task write program determine if number odd or even. code below.

#include <iostream>  using namespace std;  int number;  int main() {    cout<<"please enter number"<<endl;    cin>>number;    if(number%2==0)    {       cout<<"the number:"<<number<<" even" <<endl;    }    else()    {       cout<<"the number:"<<number<<" odd" <<endl;    }    return 0; } 

you have else() in code (above return statement). else not need parentheses after it. aware don't need have number global variable in situation. if must global, it, otherwise try keep variables scoped in class or function.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -