हिंदी

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

Advertisements
Advertisements

प्रश्न

WAP to print binary equivalent of entered decimal no.

उत्तर

#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
shaalaa.com
Data Input and Output in C-Programming
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2017-2018 (June) CBCGS
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Course
Use app×