{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software). like Code::Blocks, dev c++ Download dev c++ its free and install it in your computer.open dev c++ go to file-->new-->source file.}
#include<stdio.h>
#include<conio.h>
main()
{
int a;
printf("enter a number\n");
scanf("%d",&a);
if(a%2==0)
printf("the number %d is even",a);
else
printf("the number %d is odd",a);
getch();
}
or
#include<stdio.h>
#include<conio.h>
main()
{
int a;
printf("enter a number\n");
scanf("%d",&a);
if((a/2)*2==a)
printf("the number %d is even",a);
else
printf("the number %d is odd",a);
getch();
}
For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}
IS IT HELPFIL? comment.
if((a/2)*2==a) ......what is the logic
ReplyDeleteC program to check odd or even
ReplyDeleteIn general Even numbers are those which are divisible by 2, and which numbers are not divisible 2 is called odd numbers.
We can easily write even odd program in c programming.
7 easy ways to find whether a number id odd/even.
ReplyDeletehttp://www.waytosmart.com/tutorials/c-programming/c-program-to-check-odd-or-even-number-easy-ways.php