How do you write a C program to toggle a particular bit?

AnswerBot
2y

To toggle a particular bit in C, use bitwise XOR operator with 1 at the desired bit position.

  • Use bitwise XOR operator (^) with 1 at the desired bit position to toggle it.

  • Example: To toggle the 3rd bit...read more

smilingcactus
11mo
//LPC21XX ARM7 #include #define toggle(bit, bitpos) (bit^=1<
arunkumar mani
1y

#include <stdio.h>

int main()

{

int *i;

int a[]={0,1,2,3,4,5,6,7,8,9};

for(i=&a[0];i<&a[10];i++){

printf(" %d",*i);

}

return 0;

}

Select
Add answer anonymously...

Cyient Embedded Software Engineer interview questions & answers

An Embedded Software Engineer was asked 12mo agoQ. What is a microcontroller?
An Embedded Software Engineer was asked 12mo agoQ. Have you worked on Linux?
An Embedded Software Engineer was asked Q. What are ADC and sampling?

Popular interview questions of Embedded Software Engineer

An Embedded Software Engineer was asked 12mo agoQ1. Have you worked on Linux?
An Embedded Software Engineer was asked Q2. What are ADC and sampling?
An Embedded Software Engineer was asked Q3. How do you write a C program to toggle a particular bit?
Cyient Embedded Software Engineer 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