Reverse the bit order in a single macro.
eg. i/p = 10010101 --> o/p = 10101001

Answers were Sorted based on User's Feedback



Reverse the bit order in a single macro. eg. i/p = 10010101 --> o/p = 10101001..

Answer / balaji ganesh

#include<stdio.h>
#define f(a) strrev(a)
main()
{
char c[20];
scanf("%s",c,printf("enter bit string;"));
printf("%s",f(c));
}

Is This Answer Correct ?    0 Yes 0 No

Reverse the bit order in a single macro. eg. i/p = 10010101 --> o/p = 10101001..

Answer / 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

More C Interview Questions

What are the c keywords?

0 Answers  


Write a C program that reads a series of strings and prints only those ending in "ed"

2 Answers   Accenture,


In which layer of the network datastructure format change is done

0 Answers   Honeywell,


main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }

22 Answers   NDS, TCS,


Is there sort function in c?

0 Answers  






How to delete a node from linked list w/o using collectons?

0 Answers   Zycus Infotech,


what do u mean by Direct access files? then can u explain about Direct Access Files?

0 Answers   LG Soft,


c program to arrange digits in a no in ascending and descending order

1 Answers  


union { char ch[10]; short s; }test; test.s = 0xabcd; main() { printf("%d",ch[10]); }

3 Answers  


how does the C compiler interpret the following two statements p=p+x; q=q+y; a. p=p+x; q=q+y b. p=p+xq=q+y c. p=p+xq; q=q+y d. p=p+x/q=q+y

2 Answers   TCS, Tech Synergy,


How can I get Single byte from 'int' type variable? Can we alter single bit or multiple bits in int type variable? if so, How?

2 Answers  


Find MAXIMUM of three distinct integers using a single C statement

0 Answers  


Categories