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 Decimal
✅ C Program to Convert Hexadecimal to Decimal
#include <stdio.h>
int main() {
int num;
printf("Enter a hexadecimal number: ");
scanf("%x", &num); // Read hex input
printf("Decimal: %d\n", num);
return 0;
}
๐ Explanation:
This program converts a hexadecimal number into its decimal form.
scanf("%x", &num)→ reads a number in hexadecimal format and stores it in an integer.printf("%d", num)→ prints the decimal equivalent of the number.- No manual calculation is required since C handles the conversion automatically.
๐งพ Sample Output:
Enter a hexadecimal number: 1A Decimal: 26 Enter a hexadecimal number: FF Decimal: 255
๐ Keywords:
C program hex to decimal, hexadecimal to decimal conversion, scanf %x example, C programming basics, interview C programs
๐ Hashtags:
#CProgramming #HexToDecimal #CodingForBeginners #InterviewQuestions #LearnC
๐ Search Description:
This C program converts a hexadecimal number to decimal using scanf with %x format specifier. Simple explanation with output examples.
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