Home C Programming Tutorial

C Programming Tutorial

C Programming Tutorial

This C Programming Tutorial is written to help you understand the basic concepts of C programming language.

In this section, let see basic syntax rules that we need to follow while writing a C program. It mainly composed of tokens, identifiers, keywords, semicolons, comments, and whitespaces.

Basic Syntax in C Programming

Tokens

All identifiers, keywords, symbols, literals, etc are together known as tokens. For example, printf, curly braces ({,}), round braces ((,)), semicolon (;), any string statements inside printf or code are known as tokens.

printf (“Enter the name :”);

Here printf, ‘(‘, ‘Enter the name:’, ‘)’ and ‘;’ are the tokens.

Identifiers

These are the variable names, function names or any other user-defined names within the program. The standard format for any identifier name is, to begin with alphabets (upper or lower case) or underscore (_). It is then followed by any alphabets (upper or lower case) or digits. But it does not allow ‘@’, ‘$’ and ‘%’ to be used within the identifier. C identifiers are case sensitive.

Var1, var2, _sum, str_name, strName, fltValue, intNumValue, avg_std_100

Keywords

These are the reserved words in C, which are used to identify the variables or perform some functions within the program. For example, printf, scanf, if, else, for, while, loop, switch, int, float, char, double, struct, const, goto, return, typedef, etc.

Semicolons

All codes in C have to be terminated by a semicolon. It indicates the end of the line of the code.

printf (“Enter the name :”);
getchar ();
return 0;

Comments

Comments are the non-compliable lines of code in the program. They are used to give information about the code. When the compiler encounters comments, it ignores those lines and proceeds with the next compliable code. In C comments are written within ‘/*’ and ‘*/’ for multiline comments and single-line comments are written after ‘//’.

/* defines an equivalent notation for ‘=’ as ‘EQ’.
Whenever the compiler sees EQ in the code, it replaces it by ‘=’*/

// defines an equivalent notation for ‘=’ as ‘EQ’.

Whitespaces

Whitespaces are used to separate two identifiers, keywords, any tokens or to have a blank line, new line, etc. It differentiates any tokens from other while compiling and when a user sees the code

printf (“Enter the name :”);
sum = var1 + var2;

In next articles on C Programming Tutorial we will cover more topics on C programming language.

Identifiers in C Programming

Identifiers in C Programming

Identifiers are the user defined terms or names in the code, mainly used to identify variables, structures,  function etc. They are not part of...
Variables in C Programming

Variables in C Programming

Identifiers are of two types: variables and functions. The rule for creating names and using them remains the same. But the functionalities are different....
Constants in C Programming

Constants in C Programming

Constants are also variables but their values will not change throughout the program. They are also called as literals. They can be integer constants,...
Data Types in C programming

Data Types in C programming

When we code in a program, we need to store certain values for latter use in the program. Such values need to be stored...
Storage Classes in C Programming

Storage Classes in C Programming

When we create a variable, it is actually creating a memory space in system to hold the value. In other words a variable is...
Automatic Storage Class in C programming

Automatic Storage Class in C programming

This is a storage class for local variables. That means these types of variables are defined within a block or function and their scope...
Register Storage Class in C Programming

Register Storage Class in C Programming

This is also used for the local variables but used when faster access is required. This type of variable is stored in the CPU...
Static Storage Class in C Programming

Static Storage Class in C Programming

This is a storage class for global variables. That is, it will have scope in the block or function in which it is defined...
External Storage Class in C Programming

External Storage Class in C Programming

This storage class is also used for global variables. It also acts like a static variable. But its scope is extended to other files...
Operators in C programming

Operators in C programming

When we code a program, our main goal is to perform some operations on various variables. These operations may be arithmetic or logical operations....

Stay connected

9,233FansLike

Latest article

Multiplication of two matrices

Multiplication of two matrices

Given two matrices, this function will multiply the two matrices and prints the result. Here, necessary and sufficient condition is the number of columns...
Subtraction of two matrices

Subtraction of two matrices

Given two matrices, we will write a function that subtracts the given matrices. Example INPUT A = { {1, 4, 7, 9}, {1, 6, 7, 6}, {6, 3, 7,...
Check if two given matrices are identical

Check if two given matrices are identical

Given two matrices, we will write a function to check whether the two matrices are identical or not. That is, if all the elements...