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 program to swap bits in a character and return the value
prototype of function
char fun (char a, charb flag c)
where fun returns a char, char a is a the value char b is
the bit to be changed and flag c is the bit value
for eg: x=fun(45,7,0)
since 45 is 0010 0101
and ow x should contain the value 65 (0110 0101)



write a program to swap bits in a character and return the value prototype of function char fun (c..

Answer / abdur rab

#include <stdio.h>

char fun ( char a, char b, int flag )
{
if ( flag ) return ( a |= ( flag << ( (int) b -
1 ) ) );
return ( a &= ~( 1 << ( (int) b - 1 ) ) );
}

int main ( int argc, char* argv [] )
{

char a = 45;

printf ( "\n Before change :%d", (int) a );
printf ( "\n After change :%d", (int) fun ( a,
(char) 7, 1 ) );

return ( 0 );
}

Is This Answer Correct ?    1 Yes 9 No

Post New Answer

More C Interview Questions

explain what is a newline escape sequence?

0 Answers  


How to print India by nested loop? I IN IND INDI INDIA

4 Answers   NIIT, Wipro,


1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

1 Answers  


What is wrong with this program statement? void = 10;

0 Answers  


What is the relation between # and include<stdio.h>

5 Answers   HCL,


How can I rethow can I return a sequence of random numbers which dont repeat at all?

0 Answers  


What is a lookup table in c?

0 Answers  


Explain what header files do I need in order to define the standard library functions I use?

0 Answers  


how to create c progarm without void main()?

1 Answers   NIIT,


What is the exact difference between '\0' and ""

3 Answers  


write function to reverse char array ... without using second array

3 Answers  


What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.

0 Answers  


Categories