C program to check a number even or odd?
回答 (7)
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
#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();
}
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;
}
if (n & 1) odd;
else even;
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;
}
收錄日期: 2021-05-04 02:42:51
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20130912085557AA3pY0Z
檢視 Wayback Machine 備份