Method-2 || Check Odd Even in C++

Опубликовано: 05 Октябрь 2024
на канале: Coding Craze
2,520
like

Method-2 || Check Odd Even in C++ #coding #programming #youtubeshorts
‪@CodingCrazeIndia‬ ‪@Telusko‬

💠Instagram Page📷 :-
  / coding_craze4  
________________________________________________
🔷About C++
°°°°°°°°°°°°°°°°°
C++ is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, etc. C++ supports different ways of programming like procedural, object-oriented, functional. This makes C++ powerful as well as flexible.
C++ is also known as superset of C programming language.

🔷Program Explanation
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
An Even number is a number which is completely divisible by the number 2. If completely not divisible by 2 then that number is an Odd number.

In this program first we have declared a variable 'num' of type int (integer) which we use to store a number entered by the user.
After that we have asked the user to enter a number by using the cout, and storing that number into variable 'num' with the help of cin.
After got the input from the user, we check the condition using simple if statement.
within if statement, we are using Bitwise AND operator (&) which works at bit level of a number.
So, in this program the number will first get converted into binary form and then we compare the least significant bit (Rightmost bit) with 1.
If the least significant bit is 1 that means the number is an "odd number" otherwise "even number"
Let's take a number as an example: 17
Binary of 17 is 00010001.
As you can see the least significant bit of binary of 17 is 1 so the if condition will be true.
That means 17 is an odd number.

So, based on the result of if condition, the output will be displayed to the user. If condition is true then, if block get executed otherwise else block get executed.

Hope you understood the code and it helped you to move at least one step forward in your coding journey.
Thank you for watching the video, Hit the like button and do subscribe our YouTube channel.
________________________________________________
♦keywords :
How to check a number is even or odd?
Approach 2 to check a number is odd or even
Method to check a number is odd or even
Method 2 to check a number is even or odd in c++
Program to check a number is odd or even
C++ program to check a number is even or odd
Simple C++ program to check a number is either odd or even
learning C++ programming
programming code
C++ programming language
defining an integer variable in C++
C++ programming
learn programming
if else condition in C++
_________________________________________________
#shorts #ytshorts #codingshorts
#youtubeshorts #learncoding #learncodingonline
#coding #include #codingwithmobile #checkoddeven
#c++programming #programming #youtubeshorts #coding_for_beginners #coding_is_thinking #codinglife #codingisfun #coding_solutions #coding_knowledge
#cprogramming #coding_programs
#codingcraze #codingcrazeindia