Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

πŸ”· Square Star Pattern πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Column-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Row-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; ...

C Program to Convert Decimal to Hexadecimal

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.

Comments

Popular Posts

πŸŒ™