1. What are data types ?
int a=10;
Datatype
Variable Value or data
Semi-colon
2. What are data types ?
It decides which type of value variable will store
i.e. integer, float, character or decimal value.
3. There are 3 types of data type
• Primary or Primitive Datatype
• Derived or Non-Primitive Datatype
• User Defined Datatype
4. Primary or Primitive Datatype
Data types that have been given by the compiler or can be said as
inbuilt in it, called as primary data types or primitive data types.
• Integer type value
• Floating point type value
• Character type value
• Void type value
5. • Integer type value
Datatype Size(16 bit compiler) Range Format specifier
int or signed int 2 Byte -32767 to 32768 %d
unsigned int 2 Byte 0 to 65535 %u
short int 1 Byte -128 to 127 %hd
unsigned short int 1 Byte 0 to 255 %hu
long int or signed int 4 Byte -2,147,483,648 to 2,147,483,647 %ld
unsigned long int 4 Byte 0 to 4,294,967,295 %lu
6. • Floating point type value
Datatype Size(16 bit compiler) Range Format specifier
float 4 Bytes 1.2E-38 to 3.4E+38 %f
double 8 Bytes 2.3E-308 to 1.7E+308 %lf
long double 10 Bytes 3.4E-4932 to 1.1E+4932 %Lf
Precision
6 places
10 places
15 places
7. • Character type value and void type value
Datatype Size(16 bit compiler) Range Format specifier
char 1 Byte -127 to 128 %c
void means no value to is usually used with functions when function is not returning
any type of value it is set as void.
Example-: void addition ()
{
//code
}
8. What is Function ?
A block of code wrapped within a single name is called as functions, it is used
to do some specific task.
Types of function:-
1. Standard library functions
2. User defined functions
Standard library functions that have been already defined, in the C library within the header files,
that can directly be used like printf(), scanf().
Functions that is defined by the user, is called as user defined functions, it is a block of code that
is used to do some specific task.
9. User defined functions
A block of code wrapped within a single name is called as functions, it is used
to do some specific task.
Syntax:- return_type function_name(parameters)
{
//block of code
}
Let’s see an example of writing different kinds of function to add two
numbers.
10. void addition(int a,int b)
{
int sum =a+b;
printf(“%d”,sum);
}
int addition(int a,int b)
{
int sum =a+b;
return sum;
}
void addition()
{
int a=10, b=20;
int sum =a+b;
printf(“%d”,sum);
}
int addition(void)
{
int a=10, b=20;
int sum =a+b;
return sum;
}
No return type
with parameter
No return type
without
parameter
return type with
parameter
return type
without
parameter