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 Octal

C Program to Convert Hexadecimal to Octal

✅ C Program to Convert Hexadecimal to Octal

#include <stdio.h>
int main() {
    int num;
    printf("Enter a hexadecimal number: ");
    scanf("%x", &num);   // read hex input

    printf("Octal: %o\n", num);   // print in octal
    return 0;
}
  

πŸ“˜ Explanation:

This program converts a hexadecimal number into its octal form.

  • scanf("%x", &num) → reads a number in hexadecimal format and stores it as an integer.
  • printf("%o", num) → prints the same number in octal format.
  • No manual conversion is needed — C automatically handles it using format specifiers.

🧾 Sample Output:

Enter a hexadecimal number: 1A
Octal: 32

Enter a hexadecimal number: FF
Octal: 377
  

πŸ”‘ Keywords:

C program hex to octal, hexadecimal to octal conversion, scanf %x example, printf %o example, number system conversion in C

πŸ“Œ Hashtags:

#CProgramming #HexToOctal #CodingForBeginners #InterviewQuestions #LearnC

πŸ” Search Description:

This C program converts a hexadecimal number to octal using scanf with %x and printf with %o format specifiers. Includes explanation and sample outputs.

Comments

Popular Posts

πŸŒ™