---
title: 1.30 Basic C Syntax Reference
description: "C syntax defines how declarations, expressions, statements, functions, and blocks are written. The following example combines the basic syntax used throughout a C program. ``` #include int add(int a, int b) { return a + b; } int main(void) {…"
url: "https://edcret.in/docs/c-programming/basic-refreshers/1-30-basic-c-syntax-reference/"
updated: "2026-09-06"
category: C Programming / Basic Refreshers
---

# 1.30 Basic C Syntax Reference

C syntax defines how declarations, expressions, statements, functions, and blocks are written. The following example combines the basic syntax used throughout a C program.

```
#include <stdio.h>

int add(int a, int b)
{
    return a + b;
}

int main(void)
{
    int number = 10;

    if (number > 0)
    {
        printf("Positiven");
    }

    printf("Sum = %dn", add(number, 20));

    return 0;
}
```

### Example Output

```
Positive
Sum = 30
```

### Explanation

The main syntax elements in the example are:

| Syntax | Example | Purpose |
| --- | --- | --- |
| Header inclusion | `#include <stdio.h>` | Includes a header |
| Function definition | `int add(int a, int b)` | Defines a function |
| Parameter declaration | `int a` | Declares a function parameter |
| Block | `{ ... }` | Groups declarations and statements |
| Variable declaration | `int number;` | Declares an object |
| Initialization | `int number = 10;` | Declares and initializes an object |
| Function call | `add(number, 20)` | Calls a function |
| Conditional statement | `if (number > 0)` | Conditionally executes a block |
| Expression | `number > 0` | Produces a value |
| Statement terminator | `;` | Terminates declarations and expression statements |
| Return statement | `return 0;` | Returns a value from a function |
| Comment | `/* comment */` | Adds source-code documentation |

### Common Syntax Rules

**Statements normally end with a semicolon:**

```
int number = 10;
number = 20;
printf("%dn", number);
```

**Blocks use braces:**

```
if (number > 0)
{
    printf("Positiven");
}
```

**Identifiers are case-sensitive:**

```
int value;
int Value;
```

`value` and `Value` are different identifiers.

**Strings use double quotes:**

```
printf("Hellon");
```

**Character constants use single quotes:**

```
char letter = 'A';
```

**Keywords cannot be used as identifiers:**

```
int return;    /* Invalid */
```

These rules form the basic syntax used by the later C language features.
