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 Decimal to Hexadecimal
✅ C Program to Convert Decimal Number to Hexadecimal
#include <stdio.h>
int main() {
int num;
printf("Enter a decimal number: ");
scanf("%d", &num);
printf("Hexadecimal: %X\n", num); // %X prints in uppercase A–F
printf("Hexadecimal (lowercase): %x\n", num); // %x prints in lowercase a–f
return 0;
}
๐ Explanation:
This program converts a decimal number into its hexadecimal representation using the printf format specifiers:
- %X → prints the hexadecimal value in uppercase (A–F).
- %x → prints the hexadecimal value in lowercase (a–f).
- For example, decimal 255 will be displayed as FF and ff.
๐งพ Sample Output:
Enter a decimal number: 255 Hexadecimal: FF Hexadecimal (lowercase): ff
๐ Keywords:
C program decimal to hexadecimal, printf %X and %x, decimal to hex conversion in C, hexadecimal number system C program, beginner C examples
๐ Hashtags:
#CProgramming #HexadecimalConversion #DecimalToHex #CExamples #CodingForBeginners
๐ Search Description:
This C program converts a decimal number into hexadecimal using printf format specifiers %X and %x. It displays both uppercase and lowercase hexadecimal outputs with 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