Skip to content
Solved Examples · Example 4

Q.The textbook states that C is a free-form language, so statements can be grouped, and shows the following 'hello C' program together with its one-line form:
main()  
{  
printf("hello C");  
}  
may be written in one line like
main() {printf("hello C")};  

Karnataka PUCTextbookShort· 2mImportance★★★★★est
12% · 19/154 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

[!TLDR]

A minimal C program is just main() with one printf statement; writing it on one line is legal but harder to read, so each statement should be on its own line.

Execution begins at main(). The body, enclosed in braces, holds one executable statement, printf("hello C");, which displays whatever appears between the double quotes on the monitor. Because C is free-form, the compiler ignores extra spaces and line breaks, so the whole thing can be squeezed onto one line — but that style makes programs difficult to understand and each statement is better placed on a separate line. The complete, compilable program is:

#include <stdio.h>

int main(void)
{
    printf("hello C");
    return 0;
}

Its output is:

hello C …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.