C program to check a number even or odd?

2013-09-12 4:55 pm

回答 (7)

2013-09-13 10:36 am
✔ 最佳答案
C program to check odd or even
http://www.programmingsimplified.com/c/source-code/c-program-check-odd-even
2013-09-12 5:12 pm
Go back to the basic definition of what it means to be even or odd. It's elementary, so you should know (or be able to figure it out).

How would you check a number using paper and pencil? Do the same thing using C code.

Good luck.
N
2013-09-13 10:11 am
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("enter the value of n=%d");
scanf(%d, &n);
if(n%2==0)
printf("\n even"):
else
printf("\n odd");
getch();
}
2013-09-13 3:36 am
include<stdio.h>
main()
{ int n;
printf("Enter an integer\n");
scanf("%d",&n);
if ( n%2 == 0 )
printf("Even\n");
else
printf("Odd\n");
return 0;
}
2013-09-12 5:12 pm
if (n &amp; 1) odd;
else even;
2013-09-12 7:13 pm
Program to check whether a Number is EVEN or ODD...


#include<stdio.h>

main()
{
int n;

printf("Enter an integer\n");
scanf("%d",&n);

if ( n%2 == 0 )
printf("Even\n");
else
printf("Odd\n");

return 0;
}
2013-09-12 5:07 pm
divide by 2


收錄日期: 2021-05-04 02:42:51
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20130912085557AA3pY0Z

檢視 Wayback Machine 備份