Friday, 30 September 2016

program to check whether the no is even or odd by switch


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a;
cout<<"enter the no-:";
cin>>a;
switch(a%2)
{case 0:
cout<<"the number is even";
break;
case 1:
cout<<"the no is odd";
break;
case -1:
cout<<"the number is odd";
break;
default:
cout<<"not valid no";
}
getch();
}

No comments:

Post a Comment