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 is an identifier?

0 Answers  


Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon

0 Answers   HCL,


read a number & print all its devisors using c-program?

3 Answers  


What is size of union in c?

0 Answers  


int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of arr[]

6 Answers   Hughes,






Program to find the sum of digits of a given number until the sum becomes a single digit

8 Answers   InterGraph,


When can you use a pointer with a function?

0 Answers  


Why is the code below functioning. According to me it MUST NOT.

1 Answers  


Explain why c is faster than c++?

0 Answers  


What is keyword in c?

0 Answers  


what is the output of the following program and explain the answer #include<stdio.h> exp() { main(5) } main(int a) { printf("%d",a); return; }

3 Answers   Satyam,


Why is c called "mother" language?

0 Answers  


Categories