program:
#include <stdio.h>
#include<math.h>
#include<string.h>
int main()
{
char hex[20],c;
int n;
int i=0,decimal=0,rem;
printf("Enter any octal number: ");
scanf("%d", &n);
while(n!=0)
{
rem = n % 10;
n=n/10;
decimal=decimal+rem*pow(8,i);
++i;
}
i=0;
while(decimal!=0)
{
rem=decimal%16;
switch(rem)
{
case 10:
hex[i]='A';
break;
case 11:
hex[i]='B';
break;
case 12:
hex[i]='C';
break;
case 13:
hex[i]='D';
break;
case 14:
hex[i]='E';
break;
case 15:
hex[i]='F';
break;
default:
hex[i]=rem+'0';
break;
}
++i;
decimal/=16;
}
hex[i]='\0';
strrev(hex);
printf("Hexadecimal number :%s ",hex);
return 0;
}
output: