adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

program in c++ to check a given number is odd or even using bool keyword

Program in C++ to check a given number is odd or even using bool keyword


#include<iostream>
#include<conio.h>
 using namespace std;
 bool isEven(int n)
 {
  if(n%2==0)
    return true;
  else 
   return false; 
 }
 void main()
  {
    int a;
    cout<<"Enter a number:-";
    cin>>a;
    bool b=isEven(a);
    if(b==true)
       cout<<a<<" is Even no.";
    else
       cout<<a<<" is Odd no.";
  getch();
  }
Output:-


Post a Comment

0 Comments