Advertisement Remove all ads

Wap to Print Binary Equivalent of Entered Decimal No. - Structured Programming Approach

WAP to print binary equivalent of entered decimal no.

Advertisement Remove all ads

Solution

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,i;
clrscr();
printf(“Enter a number: “);
scanf(“%d”,&n);
printf(“Binary form is: “);
for(i=15;i>=0;i--)
{
printf(“%d”,n/(int)(pow(2,i));
n=n%(int)(pow(2,i));
}
getch();
}
Output:
Enter a number:12
Binary form is:0000000000001100
  Is there an error in this question or solution?
Advertisement Remove all ads

APPEARS IN

Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×