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 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

πŸŒ™