Write a program in the C programming language to check if the number is an odd number or an even number. Make this C program by using if-else statement. Below is the solution of this C program –
/* Write a C Program to check if the number is an odd number or an even number */ #include<stdio.h> void main() { int n; printf("Enter any number \n"); scanf("%d",&n); if(n%2!=0) { printf(" %d is an odd number",n); } else { printf("%d is an even number",n); } getch(); }
Input – Enter any number – 23
Output – 23 is an odd number
#include is missing!
Thanks
what will be the output of
#include
int main()
{
int x=3,y,z;
y=x=10;
z=x<10;
printf("x=%d y=%d z=%d\n" ,x,y,z);
return 0;
}
This section covers Simple C Programs. Every example program includes the description of the program, C code as well as output of the program. All examples are compiled and tested on a Linux system. The example programs choosen here are Simple & Basic C programs. So, they are suitable for dummies & beginners to C.
nice
Nice very useful
didn’t helped me
Please go through the below link for the 7 easy ways to find odd/even number
http://www.waytosmart.com/tutorials/c-programming/c-program-to-check-odd-or-even-number-easy-ways.php
Thanks .. nice program. We can also check for odd and even numbers using switch case statement. http://www.techcrashcourse.com/2015/11/c-program-to-check-whether-number-is-odd-even-switch-case.html