You are on page 1of 26

Previous Class…..

• Identifiers
• Constants
• Variable
Today class…
• Data types
• Variable Declaration
Data

• Data are isolated values.


Data: Examples

1. Numbers
Data: Examples

2. Letters
Data: Examples

3. Image represented as graphic images and pictures


Data: Examples

4. Audio or video
Data Items…….

• Section - character
• Branch - string
• Name - string
• Age - integer
• Height - floating-point
• Weight - floating-point
• Cost - floating-point
• Rupees - integer
• Temperature - floating-point
• Sum - integer
Data Items…….

• DOB - string
• Address - string
• Student ID - Integer or string
• Marks - integer
• Average - floating-point
• Rate of Interest - floating-point
• Radius - floating-point
• Gender - string
Data Types
• Data type or just type.

• It is one of the most important attributes of an identifier.

• It determines the possible values that an identifier can have


and the valid operations that can be applied on it.
• In C language, data types are broadly classified as:
1. Basic Data Types ( Primitive Data Types )

• The five basic data types and their corresponding keywords


available in C are:

1. Character (char)
2. Integer (int)
3. Single-Precision Floating Point (float)
4. Double-Precision Floating Point (double)
5. No value available (void)
2. Derived Data Types
• These data types are derived from the basic data types.
• Derived data types available in C are:

1. Arrays
2. Pointers
3. Functions
3. User-Defined Data Types

• The user-defined data types in C can be created by using:

1. Structures (struct)
2. Union (union)
3. Enumeration (enum)
4. Typedef (typedef)
1. Basic Data Types ( Primitive Data Types )

• The five basic data types and their corresponding keywords


available in C are:

1. Character (char)
2. Integer (int)
3. Single-Precision Floating Point (float)
4. Double-Precision Floating Point (double)
5. No value available (void)
Character (char)

• It is used to define the character values.


• Size: 1 Byte
• Range: -128 to +128
Question: When use Format Specifier?
• Format Specifier: %c Ans: To read input
To print output

Example:
main()
{
char a;
a = ‘y’;
----
}
Integer (int)

• It is used to define the decimal integer values.


• Size: 2 Byte
• Range: -32768 to +32768
• Format Specifier: %d

Example:
main()
{
int a;
a = 123;
----
}
Single-Precision Floating Point (float)
• It is used to define the floating point values with precision 6.
• Size: 4 Byte
• Range: 3.4 * 10-38 to 3.4 * 1038
• Format Specifier: %f

Example:
main()
{
float a;
a = 1.23;
----
}
Double-Precision Floating Point (double)
• It is used to define the floating point values with precision 14.
• Size: 8 Byte
• Range: 1.7 * 10-308 to 1.7 * 10308
• Format Specifier: %lf

Example:
main()
{
double a;
a = 1.23565656;
----
}
Variable Declaration

• In C language, all the variables must be declared


before there are used in the program.
What is the purpose of declare the variables?

Ans:
To reserve the amount of memory
space in RAM
What is the purpose of Reserve the Amount of Memory
Space in RAM

Ans:
• To store the values.
Fridge
• To store value in RAM,
What should we do?
Ans: To reserve the space in RAM.

• To reserve the space in RAM,


What should we do?
Ans: To declare the variable in the program

• How to declare the variables?


Synatx: Variable Declaration

datatype variable_name;

Ex: int a;

datatype variable_list;

Ex: int a, b, sum;

You might also like