


C has a number of operations, each with a certain priority. The first point to note in C is the order of operations. They restrict the ways in which one may specify calculation, and make sure that there can be no ambiguities in the way to interpret a given snippet of code. The syntax of a programming language is a set of rules specifying the way(s) in which operations may be specified to be carried out by a computer. Learn the syntax for using a preprocessor directive (specifically #include).Learn the syntax for calling functions.Learn the syntax for creating basic C programs now that variables are understood.Here, in this article, I try to explain the Basic Syntax of C Programming Language and I hope you enjoy this Syntax of C Language article.Lesson objectives: In the next article, I am going to create a sample C program and then try to explain the different parts of a C program in detail. ANSI C originally had 32 keywords, while a few more have been added later. All Keywords are usually in lowercase such as void, int, do, if, else, return, break, switch, etc. These words are specifically defined with a meaning which cannot be changed. It should be less than 32 characters, which increases the portability in ANSI C.It cannot contain blank spaces in between.Underscore ( _ ) is treated as a letter.They are a sequence of letters and digits. Identifiers are the name given to various elements such as variables, functions, etc. For e xample:Ĭ Tokens: Please have a look at the following image for the complete list of C tokens. The C program can also be called a collection of various tokens. C tokens are basically the building blocks of a C program. Token consists of identifiers, keywords, constants, data types, operators & special symbols. Tokens in C LangaugeĪ Token is a small unit of a program. In the above program, we have omitted the semicolon from the printf(“…”) statement, hence the compiler will think that starting from printf until the semicolon after return 0 statement, is a single statement and this will lead to a compilation error. The absence of a semicolon at the end of any statement will mislead the compiler to think that this statement is not yet finished and it will add the next consecutive statement after it, which may lead to a compilation (syntax) error. The semicolon ( ) is used to mark the end of a statement and the beginning of another statement. There must be at least one whitespace character (usually space) between int and age for the compiler to be able to distinguish them. Whitespace separates one part of a statement from another and helps the compiler to identify where one element in a statement, such as an int, ends and the next element begins. Whitespace is the term used in C to describe blanks, tabs, newline characters, and comments. At the end of this article, you will understand the Syntax of the C Language.

#Basic programming language syntax how to
Please read our previous article, where we discussed how to create a project using CodeBlocks IDE as well as how to compile debug and run projects in CodeBlocks IDE. In this article, I am going to discuss the Basic Syntax of the C Program in detail. Data Structures and Algorithms Tutorials.
