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
Why static is used in c?
What is static identifier?
What does the error message "DGROUP exceeds 64K" mean?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
What are the functions to open and close the file in c language?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
What is difference between class and structure?
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
Was 2000 a leap year?
any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()
Do array subscripts always start with zero?
What is the total generic pointer type?
write a program to generate address labels using structures?
Explain what are its uses in c programming?
Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80