Tech Study

C Program to Check Even or Odd using Functions

Introduction

I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.

#include <stdio.h>
 
int isEven(int num)
{
    return !(num & 1);
}
int main()
{
    int num;
 
    // Inputting number from user
    printf("Enter any number: ");
    scanf("%d", &num);
 
    // If isEven() function return 0 then the number is even
    if(isEven(num))
    {
        //printing even number
        printf("The number is even.");
    }
    else
    {
        //printing odd number
        printf("The number is odd.");
    }
 
    return 0;
}
 

Result

Write C program to check even or odd using functions
Write C program to check even or odd using functions

 

Here are some more example of c program for practice :

C Program to check whether an integer entered by the user is odd or even

C program to check number is positive, negative or zero

TaggedWrite C program to check even or odd using functions

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more