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

my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

0 Answers  


What is the condition that is applied with ?: Operator?

0 Answers  


What is the difference between array and structure in c?

0 Answers  


Which function in C can be used to append a string to another string?

0 Answers  


What is the use of linkage in c language?

0 Answers  






pgm to find middle element of linklist(in efficent manner)

4 Answers   Huawei,


Explain the difference between structs and unions in c?

0 Answers  


Define macros.

0 Answers   Tech Mahindra,


how to make a scientific calculater ?

0 Answers  


Is c object oriented?

0 Answers  


c pgm count no of lines , blanks, tabs in a para(File concept)

2 Answers  


What does %c do in c?

0 Answers  


Categories