Check The Given Number Is Even Or Odd




Source code :-

#include<stdio.h>
int main()
{
    int n;
    printf("Enter the number: ");
    scanf("%d",&n);
    if(n%2==0)
        printf("Enter number %d is even number\n",n);
    else
        printf("Enter number %d is odd number\n",n);   
    return 1;   
}

Input-Output :- 

abhi@hp-15q-laptop:~$ gcc even_odd.c
abhi@hp-15q-laptop:~$ ./a.out
Enter the number: 123
Enter number 123 is odd number.

abhi@hp-15q-laptop:~$ gcc even_odd.c
abhi@hp-15q-laptop:~$ ./a.out
Enter the number: 1234
Enter number 1234 is even number.

Post a Comment

أحدث أقدم