Write a program to display the entered decimal number into octal and hexadecimal number system.



#include "stdio.h"

main()
{
int x;
clrscr(); /* to clear the screen */

printf("Enter any decimal number");
scanf("%d", &x);
printf("\n in decimals %d ",x);

printf("\n in octal %o",x);

printf("\n in hexadecimal %x",x);
}



Output: If x = 10, the output will be
in decimals 10
in octal 12



in hexadecimal a
If x = 152,


the output will be


in decimals 152
in octal 230
in hexadecimals 98.


No comments:

Post a Comment