Tuesday, March 2, 2010

DECIMAL TO BINARY

INPUT       : 7
OUTPUT   : 0000000000000111(16bit)
                    0000000000000000000000000000111(32bit)

Poster         :Avinash



Solutioions:


BY AVINASH


#include"stdio.h"
#define BIT32 31
#define BIT16 15
void DeciToBinary(int iTempDeci, int iBitType);
int main()
{
    int iDeci = 0,iBitType = 0;
    printf("Enter the Number :");
    scanf_s("%d",&iDeci);
    printf("\n");
    printf("ENTER 1 For 16bit,Enter 2 32bit:");
    scanf_s("%d",&iBitType);
    if(1 == iBitType)
        DeciToBinary(iDeci, BIT16 );
    if(2 == iBitType)
        DeciToBinary(iDeci, BIT32);
    return 0;
}


void DeciToBinary(int iTempDeci, int iBitType)
{
    int iCount = 0;
    for(iCount = iBitType; iCount >= 0; iCount--)
    {
        if(iTempDeci & (1<
            printf("1");
        else
            printf("0");
    }

}

No comments:

counter