All articles
c

A program to explain COMPOUND IF

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 016

The following code shows how to write a program to explain COMPOUND IF

Program

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

Result

Enter a no.: 7
7 is odd

Comments