Data Types in C language

150 views 8 slides Apr 03, 2023
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

Explained data types in C programming language in detail. All the data types in C language are covered in detail. The following are the data types in C language : int, float. char, double/


Slide Content

Data Types in C

What is a Data Type? A data type is an attribute of a variable that determines the types of data it can store and the operation that can be performed on it. Each programming language provides different data types to support different types of data and operation. C is a strongly typed language which means all variable must have a data type associated with them In C programming language, there are built-in data types that can be used to define variable, as well as user-defined data types that can be created using the struct keyword.

Built-in Data Types C language provide built-in data types to define variable. The following are the built-in data types in C: Character Integer Floating Point Double

Character The char data type is used to represent single characters such as 'a', 'b', 'c', etc. The size of char data type is 1 byte. The range of values for char data type is from -128 to 127 or 0 to 255. To create a variable of character data type: char variable_name ;

Integer The int data type is used to represent integer values such as 1, 2, 3, etc. The size of int data type is 2 or 4 bytes depending on the system architecture. The range of values for int data type is from -32,768 to 32,767 for 2-byte int , and from -2,147,483,648 to 2,147,483,647 for 4-byte int. There are other integer data types such as short, long, and long long , with different sizes and ranges. To create variable of integer data type: int variable_name ;

Floating Point The float and double data types are used to represent floating-point values such as 1.2, 3.14, etc. The size of float data type is 4 bytes and the size of double data type is 8 bytes. The range of values for float and double data types are system-dependent . To create a variable of type float and double: float variable_name ; double variable_name ;

Void Data Type The void data type represents the absence of a value. It is used to specify that a function returns no value or that a pointer points to no specific data type.

User Defined Data Type C language allows users to define their own data types using the struct keyword. A struct is a collection of variables of different data types. A struct can be used to group related variables and make the code more readable.