C basics #2 - Syntax

January 23, 2023

C is a popular general-purpose programming language that was first developed in the 1970s. It is widely used for developing operating systems, embedded systems, and other applications. In this blog post, we will cover the basic syntax of the C programming language and provide some examples to help you get started.

Comments

Comments are used to explain the code and are ignored by the compiler. Comments in C are denoted by the characters /* and */.

For example:

/* This is a comment */

Variables

Variables are used to store data in a program. In C, variables must be declared before they can be used. The basic syntax for declaring a variable is:

data_type variable_name;

For example:

int age;
float price;
char grade;

Data Types

C supports several built-in data types, including:

  • int for integers
  • float for decimal numbers
  • double for large decimal numbers
  • char for single characters
  • void for empty or non-existent values

Operators

C supports several types of operators, including:

  • Arithmetic operators: +, -, *, /, %
  • Comparison operators: ==, !=, >, <, >=, <=
  • Logical operators: &&, ||, !