Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / kishore batta

#include<stdio.h>
int main()
{
int number=0,set_bit=0,result=0;
printf("Enter the number:");
scanf("%x",&number);
printf("which bit to be set?:");
scanf("%x",&set_bit);
result=number|(0x1<<(set_bit-1));
printf("After setting the bit, the result is:%x
",result);
return 0;
}
OUTPUT:
Enter the number:1
which bit to be set?:4
After setting the bit, the result is:9

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a stream in c programming?

1099


Write a code on reverse string and its complexity.

993


What is c preprocessor mean?

1256


How can you allocate arrays or structures bigger than 64K?

1089


What is difference between arrays and pointers?

1026


Differentiate between calloc and malloc.

1234


A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile

1061


In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]

2429


write a programming in c to find the sum of all elements in an array through function.

2133


What does *p++ do? What does it point to?

1012


How variables are declared in c?

1001


List some of the static data structures in C?

1166


Explain the properties of union.

1031


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

3040


An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array

1101