C Syntax & Output

Headers, main, printf and comments.

✍️ 2 exercises in this lesson
  • #include <stdio.h> loads the standard input/output library, which provides printf().
  • Every program starts in the main() function.
  • Statements end with ; and blocks use { }.
  • \n inserts a new line; \t a tab.
  • return 0; tells the system the program finished successfully.

Comments: // single line and /* multi-line */.

Key Takeaways: C Syntax & Output

Mastering C Syntax & Output helps you write clean and reliable C code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

C Syntax & Output Code Example

C
#include <stdio.h>

int main() {
    // Print on separate lines
    printf("Line one\n");
    printf("Tab\tseparated\n");
    /* printf("This is commented out"); */
    printf("%d + %d = %d\n", 2, 3, 2 + 3);
    return 0;
}
Output
Line one
Tab	separated
2 + 3 = 5
Run this example on your own computer. The "Get Started" lesson shows how to set it up.

C Syntax & Output Practice Exercises

Check what you learned in “C Syntax & Output”.

/ 2 solved
Fill in the blank

Print text in C.

("Hello\n");
✓ Correct! Not quite. Try again.
Multiple choice

What does return 0; in main mean?

✓ Correct! Not quite. Try again.
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services