C++ Language Programming

Posted on at


#include <iostream>

using namespace std;

void main()

{

int choice,a,x,y;

cout<<"Press 1 to find whether the numbers are odd or even"<<endl;

cout<<"Press 2 to find the numbers are divisible by 5"<<endl;

cout<<"Press 3 to add the two numbers"<<endl;

cout<<"Press 4 to subtract the two numbers"<<endl;

cout<<"Press 5 to multiply the two numbers"<<endl;

cout<<"Press 6 to divide the two numbers"<<endl;

cin>>choice;switch(choice){case 1: cin>>a; if(a%2==0) { cout<<"Even"<<endl; } else { cout<<"Odd"<<endl;

}

break;case 2:

cin>>a; if(a%5==0)

{

   cout<<"Divisible by five"<<endl;

}

else

{

cout<<"Not Divisible by five"<<endl;

}

break;case 3:

cin>>x>>y; a=x+y;

cout<<"Sum of two numbers"<<endl;

break;case 4:

cin>>x>>y; a=x-y;

cout<<"Subtraction of two numbers"<<endl;

break;case 5:

cin>>x>>y; a=x*y;

cout<<"Multiplying two numbers"<<endl;

break;case 6:

cin>>x>>y; a=x/y;

cout<<"Dividing two numbers"<<endl;

break;

}

}



About the author

160