Skip to content

Commit a83796d

Browse files
committed
Create problem4.c
1 parent de40022 commit a83796d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

problem4.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//Solution by Pavithra B, 111712205071, IT dept.
2+
3+
#include<stdio.h>
4+
int main(){
5+
long int decimalNumber,remainder,quotient;
6+
int i=1,j,temp;
7+
char hexadecimalNumber[100];
8+
9+
printf("Enter any decimal number: ");
10+
scanf("%ld",&decimalNumber);
11+
12+
quotient = decimalNumber;
13+
14+
while(quotient!=0){
15+
temp = quotient % 16;
16+
17+
//To convert integer into character
18+
if( temp < 10)
19+
temp =temp + 48;
20+
else
21+
temp = temp + 55;
22+
23+
hexadecimalNumber[i++]= temp;
24+
quotient = quotient / 16;
25+
}
26+
27+
printf("Equivalent hexadecimal value of decimal number %d: ",decimalNumber);
28+
for(j = i -1 ;j> 0;j--)
29+
printf("%c",hexadecimalNumber[j]);
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)