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


Please Help Members By Posting Answers For Below Questions

What is volatile variable in c?

753


Why can arithmetic operations not be performed on void pointers?

706


we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?

911


What is array of pointers to string?

665


What is 2c dna?

699






What do you mean by scope of a variable in c?

632


Explain what is output redirection?

759


How can I automatically locate a programs configuration files in the same directory as the executable?

723


Why void is used in c?

666


What is the benefit of using const for declaring constants?

687


What is string function c?

656


What does return 1 means in c?

666


Is python a c language?

651


A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

708


Why is void main used?

700