Computer Science, asked by vlike2dream, 7 hours ago

Write a C program to enter two numbers and check if anyone of the numbers is even and display a message accordingly. ( Eg: one of the number is even or both numbers are not even)

Answers

Answered by RedProgrammer
0

Answer:

#include <stdio.h>

int main()

{

   

   int number1, number2;

   

   printf("Enter first number: ");

   scanf("%d", &number1);

   

   printf("Enter first number: ");

   scanf("%d", &number2);

   if(number1 % 2 == 0 && number2 % 2 == 0) {

       printf("Both %d and %d are even numbers", number1, number2);

   }else if(number1 % 2 == 0) {

       printf("%d is an even number", number1);

   }else if(number2 % 2 == 0) {

       printf("%d is an even number", number2);

   }

   return 0;

}

Explanation:

  1. We are accepting 2 numbers from the user.
  2. Then we are checking if both the number are even or not.
  3. Then we are checking if number 1 is even or not, then we are printing it.
  4. Lastly, we are checking if number 1 is even, then we are printing it

Similar questions