Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

πŸ”’ C Program to Print Hollow Continuous Number Square πŸ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } πŸ“‹ Copy Code πŸ’» Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 πŸ”’ C Program to Print Standard Hollow Binary Row Square πŸ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

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

πŸŒ™