Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to find the binary of a number?

Answer Posted / alle balraj

void main()
{
int i,n,p=0,j;
int a[10];
clrscr();
printf("Enter the value of n:\n");
scanf("%d",&n);
i=n;
while(i!=1)
{
if(n==1)
{
a[p]=1;
break;
}
if(n%2==0)
{
a[p]=n%2;
}
else
{
a[p]=n%2;
}
n=n/2;
i=n+2;
i--;
p++;
}
for(j=p;j>=0;j--)
{
printf("%d",a[j]);
}

getch();
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages of union?

1067


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1086


Explain what is the difference between far and near ?

1103


what are bit fields in c?

1706


What is the purpose of sprintf() function?

1117


What is const keyword in c?

1161


What’s a signal? Explain what do I use signals for?

1105


Can a local variable be volatile in c?

989


Explain what are preprocessor directives?

1065


Are comments included during the compilation stage and placed in the EXE file as well?

1080


Why functions are used in c?

1133


What is the advantage of a random access file?

1196


Is return a keyword in c?

1075


What is self-referential structure in c programming?

1214


How do you generate random numbers in C?

1193