Write C program to check even or odd number using switch case


Introduction

Write C program to check even or odd number using switch case


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>

int main()
{
    int num;

    //Reading a number from user
    printf("Enter any number to check even or odd: ");
    scanf("%d", &num);

    switch(num % 2)
    {
        //If n%2 == 0
        case 0: printf("Number is even");
                break;

        //Else if n%2 == 1
        case 1: printf("Number is odd");
                break;
    }

    return 0;
}

Result

C language

     





Related Topics




Popular Posts