To check a given number is even or odd and it’s sign using bitwise operators
Description:
• Read number n from user.
• Check the 0th bit(on LSB end) of the number.
◦ if last bit is 1, number is odd.
◦ if last bit is zero, number is even.
• Check the number is positive or negative.
◦ Check the 31st bit for sign
• Prompt for continue option.
Pr-requisites:-
• If Else
• Bitwise Operators
Objective: -
• To understand the concept of
◦ Bitwise Operators
Answers
Answered by
2
Explanation:
refer to the attachment
hope it helps
Attachments:
Answered by
0
Answer:
Input: N = 11
Output: Odd
Input: N = 10 Output: Even
Attention reader! All those who say programming isn't for kids, just haven't met the right mentors yet. Join the Demo Class for First Step to Coding Course, specifically designed
for students of class 8 to 12.
The students will get to learn more about the world of programming in these free classes which will definitely help them in making a wise career choice in the future.
Similar questions