C Program To Find Whether A Given Number Is Even Or Odd
Every even number is a multiple of 2.So to say that a number is even it should be divisible by 2 otherwise it is said to be an odd number.The below code helps you find whether a given number is even or odd using C program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<stdio.h> #include<conio.h> #include<graphics.h> void main() { int num; clrscr(); printf("Enter num:\n"); scanf("%d",&num); textcolor(GREEN); if(num%2==0) printf("The Number Is Even"); else printf("The Number Is Odd"); getch(); } |
Copy the above code and paste it in C compiler and run.
In running this code there is no need to press Ctrl+F5 to get the result as getch( ); is present.
For more programs subscribe to my posts,also like and share.
Thanks For Visiting.
0 comments:
Post a Comment