Write a program to determine if the 5th bit of a given number is set or cleared.

AnswerBot
2y

To find if the 5th bit of a number is set or cleared.

  • Use bitwise AND operator with 0b10000 to check if the 5th bit is set or cleared.

  • If the result is 0, the 5th bit is cleared. If it is greater than 0...read more

SAI PRANEETH REDDY KAITHI
7mo
public class Main { public static void main(String[] args) { int number = 18; // Example number int mask = 1 << 4; // 5th bit mask (binary 00010000) if ((number & mask) != 0) { System.out.println("The...read more
Help your peers!
Select
Add answer anonymously...

Cognizant GenC Next interview questions & answers

A GenC Next was asked Q. Write a program to reverse your name.
A GenC Next was asked Q. What is your favorite technology?
A GenC Next was asked Q. What is virtual DOM and why does ReactJS use it?

Popular interview questions of GenC Next

A GenC Next was asked Q1. Write a program to reverse your name.
A GenC Next was asked Q2. What is your favorite technology?
A GenC Next was asked Q3. What is virtual DOM and why does ReactJS use it?
Cognizant GenC Next Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits