Elements of C Programming Language
Constants: Symbolic name or an entity that does not change its value during the execution of a program.
There are two major categories of a constant:
Primary Constant: This category consist basic constants of C language like integer constant, float or real integer constant, character constant.
Secondary Constant: This category consist arrays, pointers, structure, union, enum etc.
We will discuss only primary constants :
a) Integer Constant:
const int rate= 50;
In this const is a keyword, int is a data type, rate is a value , = is a assignment operator, 50 is a value, ; is a terminate operator to terminate the statement
In this value of variable rate'' will not be changed throughout the program .
b) const float or real integer:
const float pi= 3.1415;---> this is called the declaration with complete statement .
c) Character Constant:
const char ch= 'A';
a character data type value is always assigned with ''quotes.
Variables: It is the most fundamental aspect of any language.
It is a location in the Computer memory which can store value and is a given symbolic name for easy reference.
Variable declaration requires that you inform c of the variable's name and date data types.
int page_no; char grade; float salary;
int page-no, no-books;
char first, middle, last;
These all examples are the different ways of declaration for variable.
Initialisation of variables: When a variable is declared it contains and defined values for garbage values. So we can initially initialise a value to the variable.
float salary= 1200.50;
int a=10, b=20, c=30;
Expressions: An expression consist of combination of operands, operators, variables and functions calls. An expression can be arithmetic, logical, or relational.
Example of Expressions:
a+b=c [arithmetic operation]
a>b [relational operation]
a==b [logical operations]
func(a,b) [function calls]
Statement: A statement is a complete instruction to the computer. In C, statements are indicated by semicolon ; at the end.
legs =4; it is a statement.
legs=4 it is an expression.
Other examples are