Ang Blog ni Paurong!

Dahil hindi plantsado ang buhay ng tao.

A function-oriented C program that will convert a decimal input to its binary equivalent.

Posted by Paurong sa Martes, Oktubre 23, 2007

/* A function-oriented C program that will
convert a decimal input to its binary equivalent. */

#include <stdio.h>
#include <conio.h>

void main()
{
clrscr();
input();
output();
getch();
}

int d, b=0, ctr=1;

int input()
{
printf(“Input decimal number: \n”);
scanf(“%d”, &d);
return d;
}

int output()
{
for(; d!=0 ; )
{
b = b + (d % 2) * ctr;
ctr = ctr * 10;
d = d / 2;
}
printf(“Binary equivalent: %d”, b);
return 0;
}

2 Tugon to “A function-oriented C program that will convert a decimal input to its binary equivalent.”

  1. Joanne said

    ay grabe. akala ko kasama ‘to sa ala-_ _ _ _ riddles mo.

  2. wa wa…
    gusot ngrrun b tlga toh?
    thnx na din…

Mag-iwan ng Tugon

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Palitan )

Twitter picture

You are commenting using your Twitter account. Log Out / Palitan )

Facebook photo

You are commenting using your Facebook account. Log Out / Palitan )

Google+ photo

You are commenting using your Google+ account. Log Out / Palitan )

Connecting to %s

 
%d bloggers like this: