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:-
0 Comments