write a c program to change only the 3rd bit of the
particular number such that other bits are not affected..
if bitnum=10(say.. it can be any no..
Answer Posted / vadivel t
assume int holds 4bytes...
For ex:
#include <stdio.h>
int main()
{
int i = 16;
if(i & 0x04)
{
/*3rd bit is set to 1- so reset it to 0 - other bits will
not be disturbed*/
i = i & 0xFFFFFFFFB;
printf("IN IF \n");
}
else
{
/*3rd bit is set to 0- So set it to 1 - other bits will
not be disturbed*/
i = i | 0x00000004;
}
printf("%d", i);
_getch();
return 0;
}
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
Explain what is the difference between far and near ?
When do we get logical errors?
What is clrscr ()?
How can I remove the leading spaces from a string?
What is the difference between a function and a method in c?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.
What are the advantages of the functions?
How can I do graphics in c?
How do you construct an increment statement or decrement statement in C?
Write a C program in Fibonacci series.
What is structure in c explain with example?
Why is structure padding done in c?
a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor
Differentiate between a structure and a union.