Reading the Numbers on a Sefcu Check
- Selected Reading
- UPSC IAS Exams Notes
- Developer's All-time Practices
- Questions and Answers
- Effective Resume Writing
- Hr Interview Questions
- Computer Glossary
- Who is Who
C++ Plan to Check Whether Number is Even or Odd
A number is even if it is divisible past two and odd if it is non divisible by two.
Some of the even numbers are −
2, four, 6, 8, 10, 12, 14, xvi
Some of the odd numbers are −
1, iii, 5, 7, 9, 11, thirteen, 15, 17
Bank check Whether Number is Even or Odd using Modulus
A program to check whether number is fifty-fifty or odd using modulus is as follows.
Example
Live Demo
#include <iostream> using namespace std; int main() { int num = 25; if(num % 2 == 0) cout<<num<<" is even"; else cout<<num<<" is odd"; return 0; } Output
25 is odd
In the to a higher place program, the number num is divided by 2 and its remainder is observed. If the remainder is 0, then the number is fifty-fifty. If the remainder is 1, then the number is odd.
if(num % two == 0) cout<<num<<" is fifty-fifty"; else cout<<num<<" is odd";
Check Whether Number is Even or Odd Using Bitwise AND
A number is odd if it has 1 equally its rightmost bit in bitwise representation. It is even if it has 0 every bit its rightmost scrap in bitwise representation. This tin be establish by using bitwise AND on the number and ane. If the output obtained is 0, and so the number is even and if the output obtained is 1, then the number is odd.
A plan to check whether number is even or odd using Bitwise AND is as follows −
Example
Live Demo
#include <iostream> using namespace std; int main() { int num = 7; if((num & i) == 0) cout<<num<<" is fifty-fifty"; else cout<<num<<" is odd"; render 0; } Output
7 is odd
In the in a higher place program, bitwise AND is done on num and one. If the output is 0, and so num is even, otherwise num is odd.
if((num & one) == 0) cout<<num<<" is fifty-fifty"; else cout<<num<<" is odd";
Published on 26-Sep-2018 13:46:30
- Related Questions & Answers
- 8085 plan to check whether the given number is even or odd
- Coffee program to find whether given number is fifty-fifty or odd
- Check whether given floating betoken number is even or odd in Python
- Python Programme to Determine Whether a Given Number is Even or Odd Recursively
- Golang Program to Determine Recursively Whether a Given Number is Even or Odd
- C Programme to Bank check if count of divisors is even or odd?
- How to Check if a Number is Odd or Fifty-fifty using Python?
- C# Plan to check if a number is Positive, Negative, Odd, Even, Zero
- Java Program to check if count of divisors is even or odd
- PHP program to check if the total number of divisors of a number is even or odd
- C++ Program to Cheque Whether a Number is Prime number or Non
- C++ Programme to Check Whether a Number is Palindrome or Non
- C Program to Bank check Whether a Number is Prime number or not?
- Cheque whether product of 'due north' numbers is even or odd in Python
- Check whether the length of given linked listing is Even or Odd in Python
Reading the Numbers on a Sefcu Check
Source: https://www.tutorialspoint.com/cplusplus-program-to-check-whether-number-is-even-or-odd
0 Response to "Reading the Numbers on a Sefcu Check"
Post a Comment