2. DERIVED DATA TYPE
• Array:
collection of similar data-type
• Pointer:
C Pointer is a special variable that can be used to store
address of another variable.
2
3. ENUMERATED DATA TYPE (ENUM)
▪ user defined data type having finite set of
enumeration constants.
▪ keyword used 'enum'
▪ Enumeration data type -named integer constants
as a list.
▪ starts with 0 (zero) by default and value is
incremented by 1 for the sequential identifiers in the
list. 3
4. ▪ Syntax:
Enum [datatype] {const1, const2… constn};
▪ Example:
enum month { Jan, Feb, Mar };
▪ /* Jan, Feb and Mar variables will be assigned to 0, 1
and 2 respectivelyby default */
4
5. enum month { Jan = 1, Feb, Mar };
▪ /* Feb and Mar variables will be assigned to 2 and 3
respectively by default */
enum month { Jan = 20, Feb, Mar };
▪ /* Jan is assigned to 20. Feb and Mar variables will
be assigned to 21 and 22 respectively by default */
5
6. TYPEDEF DATA TYPE
It is used to create new data type.
commonly used to change existing datatype with
another name.
Syntax:
typedef [datatype] newdatatype;
Example:
typedef int integer;
integer rollno;
6
7. STRUCTURE DATA TYPE
collection of different data types which are grouped
together
each element in a C structure is called member.
7
9. Declaring a variable as constant
Eg: const int classsize = 40;
This tells the compiler that the value of the int
variable classsize must not be modified by the
program.
9
10. Declaring a variable as volatile
By declaring a variable as volatile, its value may be
changed at any time by some external source.
Eg: volatile int date;
10
11. OPERATORS OF C
• C supports a rich set of operators.
• Operators are used in programs to manipulate data and
variables.
• forms a part of the mathematical of logical expressions.
• Categories.
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operators
5. Increment and Decrement operators
6. Conditional operators
7. Bitwise operators
8. Special operators
13. Integer Arithmetic
When both the operands in a single arithmetic expression are integers,
the expression is called an integer expression , and the operation is
called integer arithmetic.
During modulo division the sign of the result is always the sign of the first
operand.
-14 % 3 = -2
-14 % -3 = -2
14 % -3 = 2
14. Real Arithmetic
• An arithmetic operation involving only real operands
is called real arithmetic.
• If x and y are floats then we will have:
1) x = 6.0 / 7.0 = 0.857143
2) y = 1.0 / 3.0 = 0.333333
The operator % cannot be used with real operands
15. Mixed-mode Arithmetic
When one of the operands is real and the other is
integer, the expression is called a mixed-mode
arithmetic expression and its result is always a real
number.
eg: 1) 15 / 10.0 = 1.5
16. RELATIONAL OPERATORS
• Comparisons can be done with the help of
relational operators.
• The expression containing a relational operator
is termed as a relational expression.
• The value of a relational expression is either one
or zero
17. Operator Meaning
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
== Equal to
!= Not equal to
RELATIONAL OPERATORS
18. LOGICAL OPERATORS
• C has the following three logical operators.
OPERATOR DESCRIPTION EXAMPLE
&& AND X=9,Y=8
X<10 && Y >0
Returns TRUE
|| OR x=9, y=x==5 || y == 5
! NOT