Friday 17 January 2014

Filled Under:

Write a program to convert decimal to binary??

#include<stdio.h>
#include<conio.h>
void main()
{
    int dec,temp,bin[100],i=1,j;

    printf("Enter A Decimal Number:");
    scanf("%d",&dec);

    temp=dec;

    while(temp!=0)
    {
        bin[i++]=temp%2;
        temp=temp/2;
    }

    printf("The Equivalent Binary Number Of %d is ",dec);

    for(j=i-1;j>0;j--)
    {
        printf("%d",bin[j]);
    }

    getch();
}

0 comments:

Post a Comment