0% found this document useful (0 votes)
27 views2 pages

Nama: Fani Andi NIM: 1318084 Kelas: D

This document contains the name, student ID number, and class of a student named Fani Andi with student ID 1318084 who is in class D. It also contains C code to convert a binary number to hexadecimal. The code prompts the user to enter the number of bits, then accepts binary numbers in groups of 4 bits and converts each group to decimal then displays the full hexadecimal number.

Uploaded by

smk tama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Nama: Fani Andi NIM: 1318084 Kelas: D

This document contains the name, student ID number, and class of a student named Fani Andi with student ID 1318084 who is in class D. It also contains C code to convert a binary number to hexadecimal. The code prompts the user to enter the number of bits, then accepts binary numbers in groups of 4 bits and converts each group to decimal then displays the full hexadecimal number.

Uploaded by

smk tama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

NAMA : FANI ANDI

NIM : 1318084

KELAS :D
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <conio.h>

void awal(void)
{
char c[5],b[5],e;
int a,d[16],i,j,bit;

clrscr();
printf("Jumlah bit [4,8,12,...]? "); scanf("%d",&bit);

for(j=0;j<bit/4;j++)
{
printf("\nMasukkan Bilangan Biner [4-bit]: "); scanf("%s",&c);
e=strlen(c);
for(i=0;i<e;i++)
{
if(c[i]=='1')
a=1;
else if(c[i]=='0')
a=0;
b[i]=a*pow(2,(e-1)-i);
}
d[j]=b[0];
for(i=1;i<e;i++)
d[j]+=b[i];
}
printf("\nBilangan Heksadesimalnya adalah ");
for(j=0;j<bit/4;j++)
if(d[j]==10)
printf("A");
else if(d[j]==11)
printf("B");
else if(d[j]==12)
printf("C");
else if(d[j]==13)
printf("D");
else if(d[j]==14)
printf("E");
else if(d[j]==15)
printf("F");
else
printf("%d",d[j]);
getch();
awal();
}
void main(void)
{
awal();
}

You might also like