Tech Study

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

#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

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

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

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more