C INTRODUCTION
‘C’ was an offspring of the ‘Basic Combined Programming Language’ (BCPL) called B, developed in the 1960’s at Cambridge University. B Language was modified by Dennis Ritchie and was implemented at Bell Laboratories in 1972. The new language was named C.
MODULARITY:
In programming, the term structure has two interrelated meanings. Program whose structure consists of interrelated segments arranged in a logical and easily understandable order to form an integrated and complete unit, are called modular programs. The smaller segments used to construct a modular program are called modules. Since each module is designed to perform a specific function, the modules themselves are called functions in C.
PORTABILITY:
C matches the capabilities of many computers, it is independent of any particular machine architecture.
DATA TYPES AND FORMAT SPECIFIERS:
Data type | Meaning | Size | Format Specifier |
char | holds only one character | 1 Byte |
%c |
int | holds an integer | 2 Byte |
%d |
float |
holds a single precision
floating point number |
4 Byte | %f |
double |
holds a double precision
float point number |
8 Byte | %lf |
Note: Precision refers to the no. of significant digits after the decimal point.
CONSTANTS AND VARIABLES:
A constant does not change its value during the entire execution of the program.
Ex: 3.14, 510, 3
A variable is an entity that has a value and is known to the program by a name. It’s value may change during the execution of the program.
Ex: int x; => x is a variable of integer data type.
An operator, in general, is a symbol that operates on a certain data type. For example, the operator ‘+’ performs addition operation.
Types of operator:
i) Arithmetic operators:
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo division (It gives remainder after division)
ii) Relational operators:
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= No equal to
iii) Logical operators:
&& Logical AND
|| Logical OR
! Logical NOT
iv) Assignment operators:
This operator evaluates the expression on the right, and assigns the resulting value to the variable on the left.
Ex: =, -=, +=, /=, *=.
v) Increment and decrement operators:
This operators are extensively used in for and while loops.
syn: a) ++
b) --
vi) Conditional operators(Ternary operators):
It consists of two symbols, the question mark(?) and the colon(:)
syn: var = var1>var2 ? var1 : var2 ;
Ex: x = I > j ? i : j ;
vii) Comma operator:
A set of expressions, seperated by commas is a valid construct in the C language. It is used to combine two
related expressions into one, making programs more compact.
Ex: int i, j;
for(sum=0, i=1; i<10; i++, sum+=i)
viii) Other operators:
The operator size of gives the size of the data type or the variables in terms of bytes occupied in memory. Another operator is the member selection operator (. and ->) which is used with structures and unions. Pointer operators * and & are explained in detailed in later chapter.
ESCAPE SEQUENCE OR ESCAPE CHARACTORS:
\a Beep (Alert)
\b Back space
\n New line
\t Horizontal tab
\v vertical tab
\\ Back slash
\’ Single quote
\” Double quote
SHORT KEY to compile, execute and display the output:
alt + F9 => Compilation
cntrl + F9 => Execution
alt + F5 => Display the Output