Odd Or Even Example C++ Program Using function
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 Using Functions
/*## Odd Or Even Example Program Using Functions In C++*/
/*## Calculation C++ Programs, Datatype C++ Programs, Basic C++ Programs*/
#include <iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
string odd_even(int i);
int main() {
// Declare Variables
int number;
cout << "Simple C++ Program : Odd Or Even Example Program Using Functions\n";
//Read Value
cout << "\nEnter an integer : ";
cin>>number;
//Call Function and Print Result
cout << "\n\nResult : " << odd_even(number);
getch();
return (0);
}
string odd_even(int number) {
if (number % 2 == 0) {
return "YOUR NUMBER IS EVEN NUMBER";
} else {
return "YOUR NUMBER IS ODD NUMBER";
}
}
Sample Output
Simple C++ Program : Odd Or Even Example Program Using Functions
Enter an integer : 5
Result : YOUR NUMBER IS ODD NUMBER
---
Simple C++ Program : Odd Or Even Example Program Using Functions
Enter an integer : 6
Result : YOUR NUMBER IS EVEN NUMBER
C++ Common Example Programs
- Factorial Using Loop Example Program In C++
- Factorial Using Function Example Program In C++
- Factorial Using Recursion Example Program In C++
- Find Prime Number ( Method1 ) Example Program In C++
- Find Prime Number ( Method2 ) Example Program In C++
- Fibonacci series Example Program In C++
- Example Program For Multiplication Value Using For Loop In C++
- Area Of Circle Example C++ Program
- Area Of Square Example C++ Program
- Area Of Rectangle Example C++ Program
- Odd Or Even Example C++ Program
- Sum of Digits Example C++ Program
- Circumference Of Circle C++ Example Program
- Simple C++ program for print the sum of all odd numbers from 1 to n
- Simple Program for Convert Feet to Inches In C++ Programming
- Odd Or Even Example C++ Program Using function
Read More Articles
- 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 Function Overloading Using C++ Programming
- Simple Program for Single Inheritance Using C++ Programming
- Simple Example Program For Copy Constructor In C++
- Simple Program for Inline Function without Class Using C++ Programming
- Simple Example Program For Constructor Overloading In C++
- Simple Example Program for Inline Function Using C++ Programming
- Factorial Using Function Example Program In C++
- Simple Addition ( Add Two Integers ) Example Program
- Simple Example Program For Constructor In C++
- Simple Stack Program in C++ Programming
- Simple Program for Read user Input Using cin
- Factorial Using Loop Example Program In C++
- Simple Program for Friend Function Using C++ Programming
- Simple Program for Static Data and Member Function Using C++ Programming
- Simple Program for Multiple Inheritance Using C++ Programming
- Simple Program for Unary Operator Overloading Using C++ Programming
- Simple Copy Constructor Example Program For Find Factorial In C++
- Do While Loop Example Program In C++
- Simple Program for Function Template Using C++ Programming