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
works at
//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;
}
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?
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app



Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
COMMUNITIES

REVIEWS
SALARIES
INTERVIEWS
Contribute to help millions!
Write a review
Share interview
Contribute salary
Add office photos
Add office benefits