Even Number : If we divide number by 2 and remainder is 0 is called Even Number.
Odd Number : If we divide number by 2 and remainder is 1 then that number is called Odd Number.
1) Using Modulus Operator
2) Using Conditional Operator
3) Using Bit-wise Operator
Odd Number : If we divide number by 2 and remainder is 1 then that number is called Odd Number.
1) Using Modulus Operator
#include<stdio.h>
int main()
{
int no;
printf("Enter No : ");
scanf("%d",&no);
if( no % 2 == 0 )
printf("Even Number");
else
printf("Odd Number");
return 0;
}
#include<stdio.h>
int main()
{
int no;
printf("Enter No : ");
scanf("%d",&no);
no % 2 == 0 ? printf("Even Number") : printf("Odd Number");
return 0;
}
#include<stdio.h>
int main()
{
int no;
printf("Enter No : ");
scanf("%d",&no);
if ( (no & 1) == 0 )
printf("Even Number");
else
printf("Odd Number");
return 0;
}
0 comments :
Post a Comment