An Interest In:
Web News this Week
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
- March 13, 2024
July 7, 2022 04:37 am GMT
Original Link: https://dev.to/itsaomi/a-simple-c-odd-or-even-checker-ch7
A Simple C Odd or Even Checker
Making a simple C++ Odd or Even Checker.
For more Source Codes visit here.
Create the basic c++ program format using header file iostream and namespace std.
#include <iostream>using namespace std;int main() { return 0;}
After this create a integer variable n, and output a message and let the user enter a number.
int n; cout<<"Enter number: "; cin>>n;
Now using if and else we will see whether the entered number is divisible by two, if it is then its a even number otherwise an odd number.
if(n%2==0) cout<<n<<" It is an Even Number"; else cout<<n<<" It is an Odd Number";
You can now complete the program and run it in any compiler to check its working.
#include <iostream>using namespace std;int main() { int n; cout<<"Enter number: "; cin>>n; if(n%2==0) cout<<n<<" It is an Even Number"; else cout<<n<<" It is an Odd Number"; return 0;}
Original Link: https://dev.to/itsaomi/a-simple-c-odd-or-even-checker-ch7
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To