Sunday, August 6, 2023

Write a C program to check whether a given number (integer) is Even or Odd.


 

Write a C program to check whether a given number (integer) is Even or Odd.


Program :-

#include <stdio.h>

int main()

{

    int number;

    scanf("%d", &number); /*An integer number is taken from the test case */

if(number % 2 == 0)

        printf("%d is even.", number);

    else

        printf("%d is odd.", number);

}


InputOutput
Test Case 1
24
24 is even.
Test Case 2
51
51 is odd.

No comments:

Post a Comment