Odd Or Even Example C++ Program
Definition
A formal definition of an even number is that it is an integer of the form n = 2k, where k is an integer;[3] it can then be shown that an odd number is an integer of the form n = 2k + 1.
Odd Or Even Example Program
/*## Check if an integer is odd or even In C++*/
/*## Calculation C++ Programs, Datatype C++ Programs, Basic C++ Programs*/
#include <iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
int main() {
// Declare Variable
int number;
cout << "Simple C++ Program : Check if an integer is odd or even\n";
cout << "\nEnter an integer : ";
cin>>number;
if (number % 2 == 0)
cout << "\nThe number you entered is an EVEN number";
else
cout << "\nThe number you entered is an ODD number";
getch();
return (0);
}
Sample Output
Simple C++ Program : Check if an integer is odd or even
Enter an integer : 5
The number you entered is an ODD number
----
Simple C++ Program : Check if an integer is odd or even
Enter an integer : 6
The number you entered is an EVEN number
Top Pages
- Simple Merge Sort Program in C++
- Scope Resolution Operator In C++
- Simple Program for Virtual Functions Using C++ Programming
- Simple Class Example Program For Find Prime Number In C++
- Simple Example Program For Parameterized Constructor In C++
- Define Constructor in Outside Class Example Program In C++
- Simple Program for Single Inheritance Using C++ Programming
- Simple Example Program For Copy Constructor In C++
- Simple Program for Function Overloading Using C++ Programming
- Simple Example Program For Constructor In C++