Home / Programs / Unsigned Octal number for integer : %o Example Program
🚀 Programming Example

Unsigned Octal number for integer : %o Example Program

👁 1,756 Views
💻 Practical Program
📘 Step Learning
Unsigned Octal number for integer : %o Example Program

💻 Program Code

#include <stdio.h> 
int main() 
{ 
    int a = 67; 
    printf("%o\n", a); 
    return 0; 
} 
                        

🖥 Program Output

103
                            

📘 Explanation

The above code is a C program that prints the octal representation of the integer value 67 using the printf() function with the format specifier %o.

Here's how it works:

  • The #include line includes the standard input/output library in the program.
  • The main() function is the entry point of the program.
  • The variable a is declared as an integer and assigned the value 67.
  • The printf() function is used to display the octal representation of a using the %o format specifier.
    • %o is a format specifier used to display an integer in octal (base 8) format.
  • The \n character is used to insert a newline after the output is printed.
  • Finally, the return 0; statement terminates the program and returns 0 to the operating system indicating that the program executed successfully.
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.