Header Ads Widget

A number is even or odd without using modulus operator

#include<stdio.h>
int main()
{
int a;
float b,n;
printf("Enter number : ");
scanf("%f",&n);
a=n/2;
b=n/2;
if(a==b)
     printf("Entered number is even");
else
     printf("Entered number is odd");
return 0;


}

Output :
Enter number : 7
Entered number is odd

Post a Comment

0 Comments