Reverse the bit order in a single macro.
eg. i/p = 10010101 --> o/p = 10101001
Answer Posted / vishnu
with out using strrev
=======================
#include<stdio.h>
#include<conio.h>
int i ;
void binary(int retval[],int num)
{
int k;
while(num >1)
{
k = num;
num =num/2;
retval[i] = k%2;
i++;
}
retval[i] =1;
}
int main()
{
int num;
int bin[20];
scanf("%d",&num);
binary(bin,num);
for(num=i;num >=0;num--)
printf("%d",bin[num]);
printf("\n");
for(num =0;num<=i;num++)
printf("%d",bin[num]);
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
what is bit rate & baud rate? plz give wave forms
What is static memory allocation?
How can I access an I o board directly?
Do you know null pointer?
Explain a file operation in C with an example.
What is volatile variable in c with example?
Do you know what are the properties of union in c?
Differentiate between a for loop and a while loop? What are it uses?
Tell me the use of bit field in c language?
what is a constant pointer in C
What are the application of void data type in c?
Why do we use null pointer?
Is it better to use a macro or a function?
What is dynamic variable in c?