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

πŸŒ™