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)
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 |
What is the use of function overloading in C?
What are structure types in C?
Can we initialize extern variable in c?
how to print 212 as Twohundreds twelve plz provide me ans soon
write a c program to calculate the income tax of the employees in an organization where the conditions are given as. (I.T. = 0 if income <100000 I.T = 10% if income _< 200000 it = 20% if income >_ 200000)
7 Answers Consultancy, DBU, FD, JK Associates, Kobe, Satyam,
what is the diference between pointer to the function and function to the pointer?
why Language C is plateform dependent
What is pointer to pointer in c?
What is void main ()?
What is pass by reference in functions?
Write a code to remove duplicates in a string.
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?
25 Answers Datamatics, Solartis, TCS, ThinkBox, Trine,