Tech Study

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

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.

#include <iostream>
using namespace std;
 
int isEven(int num)
{
    return !(num & 1);
}
 
int main(){
 
    int num;
 
    // Inputting number from user
    cout<<"Enter any number: ";
    cin>>num;
 
    // If isEven() function return 0 then the number is even
    if(isEven(num))
    {
        //printing even number
        cout<<"The entered number is even.";
    }
    else
    {
        //printing odd number
        cout<<"The entered 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

TaggedWrite C program to check even or odd using functions

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