Computer Science, asked by ritushree55, 4 months ago

Wap to enter a number and check if it is odd or even...in c++​

Answers

Answered by Anonymous
0

Answer:

#include <stdio.h>

int main() {

   int num;

   printf("Enter an integer: ");

   scanf("%d", &num);

   // True if num is perfectly divisible by 2

   if(num % 2 == 0)

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

   else

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

   

   return 0;

}

Explanation:

Answered by hari780160
0

Answer:

Example 1: Check Whether Number is Even or Odd using if else

Enter an integer: 23 23 is odd. In this program, if..else statement is used to check whether n%2 == 0 is true or not. If this expression is true, n is even if not n is odd. You can also use ternary operators ?: instead of if..else statement.

Explanation:

mark me as brainlist

Similar questions
Math, 10 months ago