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.

Operator Precedence and Its Associativity in C Programming

Operator Precedence and Its Associativity in C Programming

We have seen so many operators above. One can use all the operators in the same expression. but when multiple operators are used in...
Arrays in C Programming

Arrays in C Programming

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} Arrays Introduction In order to understand what is array...
Multi-Dimensional Arrays in C Programming

Multi-Dimensional Arrays in C Programming

Consider a 3X3 matrix. It has 3 rows and 3 columns. When we say 3 rows and 3 columns, it means that each row...
Array Memory Allocation in C Programming

Array Memory Allocation in C Programming

We have already discussed that whenever an array is declared in the program, contiguous memory to it elements are allocated. Initial address of the...
Advantages and Disadvantages of Array in C Programming

Advantages and Disadvantages of Array in C Programming

Advantages It is better and convenient way of storing the data of same datatype with same size. It allows us to store known number...
Structures in C Programming

Structures in C Programming

Introduction When we write programs to address real world requirements, variables and their datatypes are not limited single type of variables. We will have various...
Unions in C Programming

Unions in C Programming

Consider a program which has to accept the person type - student or employee and according to the person type it has to display...
Difference Between Structures and Unions in C Programming

Difference Between Structures and Unions in C Programming

Structure variables can be declared while While defining the structure After defining the structure Using typedef Structure variables can be initialized while Creating the structure...
Typedef in C Programming

Typedef in C Programming

We have seen how to declare structures and unions, and to initialize and access them. Sometimes in the program we might have to use...
Decision Making and Loops in C Programming

Decision Making and Loops in C Programming

A normal program is not a sequential execution of expressions or statements one after the other. It will have certain conditions to be checked...

Stay connected

9,228FansLike

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...