BitEasyProblem code: PGM5 |
All submissions for this problem are available.
Write the shortest C function that takes a data type of length 8 bit as argument and returns a same type of same length with all the bits of the argument reversed, i.e. the ith bit of the result is the (w-i)th bit of the argument, where w is the width of the data type in bits.
Input
Arbitrary values of 8bit length (1 2 3 4 )
Output
Integer value of corresponding input value with all its bits reversed.
Example
Input: A Output: -126
| Date: | 2010-02-26 |
| Time limit: | 1s |
| Source limit: | 50000 |
| Languages: | C |
Comments

Fetching successful submissions

Unable to submit......I think
Unable to submit......I think submitt button is not enabled.....
#include<stdio.h>int main(){
#include<stdio.h>
int main()
{
char c=8;
char b;
short d=1;
int i;
for(i=0;i<8;i++)
{
b=b<<1;
if(c&1)
{
b|=d;
}
c=c>>1;
}
printf("%d",b);
return 0;
}