Following is the program to check whether no is even or odd :-
#include<stdio.h>
int main()
{
int Num,a;
clrscr();
printf("Enter a Number\n");
scanf("%d",&Num);
a=Num%2;
if(a==0)
printf("The Entered Number is EVEN");
else
printf("The Entered Number is ODD");
return 0;
}
Output:
#include<stdio.h>
int main()
{
int Num,a;
clrscr();
printf("Enter a Number\n");
scanf("%d",&Num);
a=Num%2;
if(a==0)
printf("The Entered Number is EVEN");
else
printf("The Entered Number is ODD");
return 0;
}
Output:
Note- using the same logic we can design this program in C++ too
No comments:
Post a Comment