An odd number when divided by 2 gives remainder as 1 and an even number when divided by 2 gives remainder as 0.
#include<stdio.h>
int main()
{
int no;
printf(" Enter a no" );
scanf("%d",&no);
if(no % 2)
printf("\n Odd number);
else
printf("\n Even number");
return 0;
}
n1 % n2 = r
Mod operator(%) gives the remainder r when n1 is divided by n2.
No comments:
Post a Comment