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 purpose of scanf() and printf() functions?
In a header file whether functions are declared or defined?
What is variable and explain rules to declare variable in c?
What is the difference between array and linked list in c?
What is a good way to implement complex numbers in c?
What do you mean by dynamic memory allocation in c? What functions are used?
What are # preprocessor operator in c?
How can you increase the size of a dynamically allocated array?
What is pointer to pointer in c with example?
What is masking?
Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80
List some of the static data structures in C?
What is queue in c?
What are the different types of objects used in c?
Why we write conio h in c?