0
1.4kviews
Write a program to find out binary equivalent of given decimal no.
1 Answer
0
33views

This program will demonstrate decimal to binary conversion, on top of this use of functions and functions calling.

#include<stdio.h>
#include<conio.h>
void binary(int a[],int n)
{
    int temp=n,i=0;
    while(temp!=0)
    {
        a[i++]=temp%2;
        temp/=2;
    }
}
void disp(int arr[],int n)
{
    int i;
    printf("\n");
    for(i=0;i<n;i++)
        printf("%d\t",arr[i]);
}

void main()
{   int array[],dec;
    //array to store the result.
    printf(“Enter a decimal number:\n”);
    scanf(“%d”,&dec);
    binary(array,dec);
    disp(array,dec); }
Please log in to add an answer.