Data types are the type of data stored in a C program. Data types are used while defining a variable or functions in C. The compiler needs to understand the type of predefined data it will encounter in the program.
In this article, you will get to know What is Data Types And illustration of each type.
How this question can come in examination 2024?
Data types are the type of data stored in a C- program. Data types are used while defining a variable or function in c. Data types are used while defining a variable or functions in C. The compiler needs to understand the type of predefined data it will encounter in the program. A data type is an attribute that tells a computer how to interpret the value.
C provides various built-in data types, such as integer(int), character(char), and floating point(float). Each data type has its own sets of possible values and operations that can be performed on it. C language becomes powerful with the help of some data types linked with it. Different compilers have different data types. The variable type depends on the data type.
There are mainly Five [5] types of data types supported by the C- language.
A primary or scalar data type is used for representing a single value only. It is also called simple or fundamental data type. As these are used at the primary level in a high-level language, these are also called primary data types.
These are further sub-divided into four categories:-
A) Integer Data Type.
B) Float Data Type.
C) Double Data Type.
D) Character Data Type.
This data type is of integral type. These are without the decimal point. These are signed or unsigned. These data types contain small int (short int), int, long int. A short int is also called a small whole number. Int or normal integers are also called medium whole numbers and long ints are called long whole numbers.
Example:-
void main()
{
int i = 5;
printf(“The integer value is: %d \n”, i);
}
Integer data types have 8 bits to 32-bit data and also have different ranges for inputting the data or assigning data to the variable.
This data type contains a very small real number. These data types have at least one digit with a decimal point. These are also signed or unsigned. These data types require storage space of 32 bits and have a range of 3.4E(-38) to 3.4E(+38) for inputting the data.
Example:-
void main()
{
float f = 7.2357;
printf(“The float value is: %f \n”, f);
}
These data types have very large floating data, so are also called large real numbers. These have double precision values having the 64-bit size and a very high range of 3.4E(-4932) to 3.4E(+4932).
void main()
{
double d = 71.2357455;
printf(“The double value is: %lf \n”, d);
}
These have either a single character or a combination of characters(called string). Characters are either signed or unsigned but most characters are used as unsigned type. These have 8 bits (1 byte) internal storage.
void main()
{
char c = ‘b’;
printf(“The character value is: %c \n”, c);
}
Derived data types are derived from the scalar data type by adding some additional relationship with various elements of primary or scalar data types. The derived data type may be used for representing a single value or multiple values.
These are further subdivided into 3 types:-
a). Arrays or strings.
b). Structures.
c). Unions.
These data types are used for type definition i.e. allows the users to define a variable or an identifier, which is used for the representation of existing data types. In other words, it provides us a way to define our data type and also can define the value of a variable or an identifier stored in the main memory.
These are two types of user-defined data type:-
a) enumerated data type.
b) Typedef data type
The void is just an empty data type that depicts that no value is available. Typically, the void is used for functions. When we declare a function as void, it doesn’t have to return anything.
Void is used in three situations:
The function returns as void – A function with no return value will have the return type as void.
Function arguments as void – A function with no parameter can accept the void.
Pointers to void – It represents the address of an object, but not its type.
The pointer data type is used to store the address of another variable. A pointer can store the address of variables of any data type. Pointers allow users to perform dynamic memory allocation. They also help to pass variables by reference.
A pointer with no address is called a null pointer. A pointer with no data type is a void Pointer. It is defined by using a ‘*’ operator.
In 2024, Bangladesh was shaken by a series of widespread protests centered around the country's…
The Festival of Chariots, or Ratha Yatra 2024, is one of the most important and…
Solah Somwar Vrat Katha: 16 सोमवार के व्रत का आरंभ श्रावण मास से करें तो…
Sawan somwar vrat Katha (व्रत) से मानसिक शांति और स्थिरता प्राप्त होती है। शिवजी की…
Sawan Somwar vrat 2024- Sawan का महीना भगवान शिव का महीना माना जाता है। इस…
Wellhealth how to build muscle tag: Many people, from fitness enthusiasts to professional athletes, want…