World's most popular travel blog for travel bloggers.

# Write an algorithm, draw a flow chart and write its corresponding C program to convert a decimal number to its equivalent hexadecimal number.

, ,

Ans.  Algorithm:
Step 1:  Input NUM
Step 2:  LEN = 0 & Y=NUM
Step 3:  While (Y > 0)
HEXD[LEN]=Y%16
Y=Y/16
LEN++
Step 4: for(I=LEN-1;I>-1;I–)
IF(HEXD[I]<10)
HEXC[I]=HEXD[I]+48;
ELSE
HEXC[I]=HEXD[I]+55;
Step 5:  HEXC[I]=NULL
Step 5:  Print HEXC Program:
#include<stdio.h>
#include<math.h>
#include<conio.h>

int main()
{
int decimal_number, remainder, hexadecimal_number = 0;
int count = 0;
scanf("Enter a Decimal Number:\t");
scanf("%d", &decimal_number);
while(decimal_number != 0)
{
remainder = decimal_number % 16;
decimal_number = decimal_number / 16;
count++;
}
return 0;
getch();
}

1. The algorithm is very easy. If to follow the structure, we can easily complete the task successfully. I think that everyone will be able to use this guideline to draw a line with endpoints.

2. ghatiya algorithm hai

3. it needs correction after__int count =0;
there is printf() -- not scanf...
and also in the last statement there is also printf()--not scanf ..

Let us know your responses and feedback