I want a c program which ask for Hexadecimal number and gives output equivalent octal number. I use the code to convert int into octal using printf() function.
#include<stdio.h>
Void main(){
int i;
printf("Enter the Hax number: ");
scanf("%x",&i);
printf("Octal equivalent of number is %o",i);
}
Hexadecimal and Octal are just different representations of the same underlying number format. ie binary. So no conversion is really happening in your example. Its just that you are interpreting/printing the same number in 2 different ways. And
printfis indeed doing a good job in your exampleThe only other problematic thing I can see is
Voidmain 🙂