Key Concepts

Review core concepts you need to learn to master this subject

Syntax in C

// Statements must end in a semicolon (;) // correct printf("Hello World!"); // error printf("Hello World!") // Code elements are case sensitive // correct printf("Hello World!"); // error PRINTF("Hello World!");

The rules that dictate the correct format of code for a specific programming language are known as syntax.

Examples of syntax in C are:

  • All statements must end with a semicolon, ;
  • Keywords and other code elements are case-sensitive

When compiling C code, an error will occur when the syntax of the code is incorrect.

Hello World: Lesson
Lesson 1 of 1
  1. 1
    Congratulations on choosing to learn the C programming language! C has been around for quite some time and it is one of the foundational languages of computer science. C is an older language comp…
  2. 2
    So let’s look at our first C program! #include int main() { // output a line printf(“Hello World!\n”); } When this code is run the following text is displayed in the terminal. Hello World!…
  3. 3
    When writing in C, we need to follow a set of rules in order for the code to run properly. These rules are known as syntax. As we go through each lesson we will learn new syntax on the topics b…
  4. 4
    The main goal of our Hello World code example is to output the text “Hello World!” to the console. The line of code that outputs text is: printf(“Hello World!\n”); Let’s dive deeper into the 2 par…
  5. 5
    When we write code it is important to document the code’s behavior. One way to do this is to add comments to our code. Starting a line with a double forward slash, //, will create a comment and t…
  6. 6
    At this point, we have run our code within Codecademy’s learning environment. While this is how most of the exercises will go it is important to learn about running your code using a compiler. The…
  7. 7
    Great work getting through these first exercises! Let’s review what was covered: - C has been around for a while but is still very popular - Code syntax is a set of rules that are followed when wri…

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo