#include <stdio.h>
int main()
{
int a = 67;
printf("%o\n", a);
return 0;
}
103
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:
#include line includes the standard input/output library in the program.main() function is the entry point of the program.a is declared as an integer and assigned the value 67.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.\n character is used to insert a newline after the output is printed.return 0; statement terminates the program and returns 0 to the operating system indicating that the program executed successfully.First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.