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 volatile variable in c?
Why can arithmetic operations not be performed on void pointers?
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 ?
What is array of pointers to string?
What is 2c dna?
What do you mean by scope of a variable in c?
Explain what is output redirection?
How can I automatically locate a programs configuration files in the same directory as the executable?
Why void is used in c?
What is the benefit of using const for declaring constants?
What is string function c?
What does return 1 means in c?
Is python a c language?
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
Why is void main used?