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 Hexadecimal to Decimal

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.

Comments

Popular Posts

πŸŒ™