Program to check Even or Odd in C++ || Functions in C++ || Conditional Statement || Functions || C++
In this, we are going to see Functions, the program is based on function which Calculates, Profit or Loss.

The code given below can be used for TURBO C++ Compiler:-

#include<iostream.h>
#include<conio.h>

int number;

void get_data()
{
    cout<<"\nEnter the number to check EVEN or ODD\n";
    cin>>number;
}

void even_or_odd()
{
    if(number % 2 == 0)
    {
        cout<<"The number "<<number<<" is Even number";
    }

    else
    {
        cout<<"The number "<<number<<" is Odd number";
    }
}

void main()
{
    clrscr();
    get_data();
    even_or_odd();

    getch();
}
	
    
The code given below can be used for g++/gcc Compiler:-

#include<iostream>
using namespace std;

int number;

void get_data()
{
    cout<<"\nEnter the number to check EVEN or ODD\n";
    cin>>number;
}

void even_or_odd()
{
    if(number % 2 == 0)
    {
        cout<<"The number "<<number<<" is Even number";
    }

    else
    {
        cout<<"The number "<<number<<" is Odd number";
    }
}

int main()
{
    get_data();
    even_or_odd();

    return 0;
}
	
    
#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post