C Language Elements

C Language comes with predefined elements and user-defined elements along with some associated grammatical rules. So before starting programming, we need to understand these components.
These elements are character sets, keywords (reserved words), variables, data types, constants, expressions, and statements. We need these elements to write the program in the C language.

Character Set
C programs are written using the ASCII (American standard code for information interchange) character set. Because ASCII is a 7-bit system so that way it contains 128 (2^7) characters. In C we can use [A-Z], [a-z], [0-9] apart from that we have some character set.
Now you can understand it’s a case-sensitive language. This means all elements should be in a defined case.
Ex:-


// while, While and WHILE represents 3 distinct values.

Reserved words/KeyWords
These are predefined words with predefined meanings that also help to do some specific tasks. They are written in lowercase. In C language we have 32 keywords.

Identifiers
It’s simply a name. Here, Identifiers are used to name the variables, functions etc. Keep in mind –
Identifiers must begin with a letter, _, $ and subsequent characters can be letters, digits, _, $.
Identifiers should not be a keyword.
Ex:-


int i, my_var_name, v13, _start, $num, PI; // Legal
int 12pi, int, rect#, my no; // Illegal

Variables
For me, it’s just a Bucket. You can put something inside it, can carry it and also retrieve it when you need it.

Data types
A type is the kind of data stored in that variable. It could be int, char, float and double. identifiers, variables and type work together and make a meaningful expression.
Ex:-
int count; // int stands for integer type of value and count is our variable that will store this value

The next interesting thing is c we have some qualifiers.
Size – short, long
Sign – signed, unsigned

Constants
Constants are values that can not be changed during the execution of a program. Like in maths pi is constant and that value is 3.14 and it’s a fixed value and we can not change this value. Same in programming if we declare some variable as a constant that means inside the program no one can change that value.

Comments
C Support two styles of comments. Comments are used to increase the readability of the program we can explain the purpose of a code snippet that can help another programmer to understand your code but the compiler ignores that code.
Ex:-


// This is single line comment, for single line

/*
 * This is a multiline comment,
 * for multiple lines 
*/

Expressions
It consists of an expression followed by a semicolon.


int number = 23;

You May Also Like

About the Author: Pankaj Bisht