Course code – Course Name
Year & Semester : _____________________________
Derived Data Types
User Defined data types
int - Integer data types:
o Integers are whole numbers that can have both positive and negative values but no decimal
o Example: 0, -5, 10
o In C programming, keyword int is used for declaring integer variable.
o For example: int id;
o Here, id is a variable of type integer.
o You can declare multiple variables at once in C programming.
o For example: int id, age;
float - Floating types:
o Floating type variables can hold real numbers such as: 2.34, -9.382, 5.0 etc.
o We can declare a floating point variable in C by using either float or double keyword.
o For example: float accountBalance;
o Here, both accountBalance and bookPrice are floating type variables.
o In C, floating values can be represented in exponential form as well.
o For example: float apple = 22.442e2;
o The size of float is 4 bytes and the size of double is 8 bytes.
char - Character types
o Keyword char is used for declaring character type variables.
o For example: char test = 'h';
o Here, test is a character variable. The value of test is 'h'.
o The size of character variable is 1 byte.
o An array is a collection of data that holds fixed number of values of same type.
o For example: if you want to store marks of 100 students, you can create an array for it.
o For example: float marks;
o In C, there is a special variable that stores just the address of another variable. It is called
Pointer variable or, simply, a pointer.
o For example: int* p;
o Structure is a collection of variables of different types under a single name.
o Keyword struct is used for creating a structure.