0
897views
WAP to print binary equivalent of entered decimal no.

Subject : Structured Programming Approach

Title : Functions and Parameter

Difficulty : Medium

1 Answer
0
12views

Program:

#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
Please log in to add an answer.