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 / ajay karanam

int main()
{
int number=0;
int bitTobeChanged=0;
int endResult=0;

printf("Enter the number\n");
scanf("%d",&number);

printf("Enter the bit to be changed\n");
scanf("%d",&bitTobeChanged);

endResult=number|(0x1<<(bitTobeChanged-1));

printf("End Result = %d\n",endResult);

return 0;
}

Is This Answer Correct ?    18 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the value of uninitialized variable in c?

782


What does the error message "DGROUP exceeds 64K" mean?

972


Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

3930


What is far pointer in c?

999


how to capitalise first letter of each word in a given string?

1657


I need a sort of an approximate strcmp routine?

828


What is a char c?

789


What do the functions atoi(), itoa() and gcvt() do?

903


How to Throw some light on the splay trees?

791


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

3643


Explain low-order bytes.

804


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

2830


1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if

4186


Apart from dennis ritchie who the other person who contributed in design of c language.

1076


How many types of operator or there in c?

830