Search This Blog
Welcome to 1printf(), your ultimate destination for C, C++, Linux, Data Structures, and Microcontroller programming! ๐ ๐นLearn advanced coding techniques in C& C++ ๐นMaster Linux internals & shell scripting ๐นDeep dive into Data Structures & Algorithms ๐นExplore Embedded Systems & Microcontrollers (8051,UART, RTOS) ๐นGet hands-on coding tutorials, project ideas,and interview preparation tips Whether you're a beginner or an experienced programmer, this channel will help you
Featured
- Get link
- X
- Other Apps
C Program to Convert Hexadecimal to Octal
✅ C Program to Convert Hexadecimal to Octal
#include <stdio.h>
int main() {
int num;
printf("Enter a hexadecimal number: ");
scanf("%x", &num); // read hex input
printf("Octal: %o\n", num); // print in octal
return 0;
}
๐ Explanation:
This program converts a hexadecimal number into its octal form.
scanf("%x", &num)→ reads a number in hexadecimal format and stores it as an integer.printf("%o", num)→ prints the same number in octal format.- No manual conversion is needed — C automatically handles it using format specifiers.
๐งพ Sample Output:
Enter a hexadecimal number: 1A Octal: 32 Enter a hexadecimal number: FF Octal: 377
๐ Keywords:
C program hex to octal, hexadecimal to octal conversion, scanf %x example, printf %o example, number system conversion in C
๐ Hashtags:
#CProgramming #HexToOctal #CodingForBeginners #InterviewQuestions #LearnC
๐ Search Description:
This C program converts a hexadecimal number to octal using scanf with %x and printf with %o format specifiers. Includes explanation and sample outputs.
Popular Posts
C++ Program for Hybrid Inheritance (All Types Together)
- Get link
- X
- Other Apps
C++ Program for Function Overloading Example
- Get link
- X
- Other Apps
Comments
Post a Comment