Tuesday, 4 October 2016

To check whether a no. is even or odd using Switch statement .

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
cout<<“Enter the number “;
cin>>a;
b=a%2;
switch(b)
{
case 0:
cout<<“This number is even “;
break;
case 1:
cout<<“This number is odd “;
break;
default:
cout<<“Enter correct value “;
break;
}
getch();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...