Answers for "// write a c program to check whether a number is even or odd using ternary operator."

C
0

odd even in c with ternary operator

#include <stdio.h>
int main() {
    int num;
    printf("Enter an integer: ");
    scanf("%d", &num);
    // true if num is perfectly divisible by 2
   num % 2 == 0 ? printf("%d is even.", num); :  printf("%d is odd.", num);
    return 0;
}
Posted by: Guest on August-17-2021

Code answers related to "// write a c program to check whether a number is even or odd using ternary operator."

Code answers related to "C"

Browse Popular Code Answers by Language