[Solved] Even and Odd numbers [closed]


  • Remove the “;” after the #include
  • Add the #include <cstdlib> to get system and exit

The following compiled for me:

#include <iostream>
#include <cstdlib>

int main()
{
     using namespace std;
     int i=1;
     char ch;
     cout<<"please enter a choice"<<endl;
     cin>>ch;
     switch(ch){
     case 'e':
     case 'E':i=2;break;
     case 'o':
     case 'O':break;
     default:
         cout<<"Wrong input."<<endl;
         system ("pause");
         exit(1);
     }
     while (i<50)
         cout<<i<<" ",i+=2;    
}

2

solved Even and Odd numbers [closed]