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
What is the process to create increment and decrement stamen in c?
What does & mean in scanf?
What is the purpose of macro in C language?
What is file in c language?
What is output redirection?
What are qualifiers and modifiers c?
What is the use of header files?
Explain zero based addressing.
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
cavium networks written test pattern ..
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
What are operators in c?
Is main is user defined function?
Write a program on swapping (100, 50)
What are the various types of control structures in programming?