Introduction
Data types are provided to store various types of data that is processed in real life. A student's record might contain the following data types: name, roll number, and grade percentage. For example, a student named Anil might be assigned roll number 5 and have a grade percentage of 78.67. The roll number is an integer without a decimal point, the name consists of all alpha characters, and the grade percentage is numerical with a decimal point. C supports representation of this data and gives instructions or statements for processing such data. In general, data is stored in the program in variables, and the kind of data the variable can have is specified by the data type. Using this example, grade percentage has a float data type, and roll number has an integer data type. The data type is attached to the variable at the time of declaration, and it remains attached to the variable for the lifetime of the program. Data type indicates what information is stored in the variable, the amount of memory that can be allocated for storing the data in the variable, and the available operations that can be performed on the variable. For example, the operation S1 * S2, where S1 and S2 are character strings, is not valid for character strings because character strings cannot be multipled.
Explanation
-
In this program there are two variables, i and j, of the type integer, which is declared in statement A.
-
The variables should be declared in the declaration section at the beginning of the block.
-
If you use variables without declaring them, the compiler returns an error.
Points to Remember
-
C supports various data types such as float, int, char, etc., for storing data.
-
The variables should be declared by specifying the data type.
-
The data type determines the number of bytes to be allocated to the variable and the valid operations that can be performed on the variable.
No comments:
Post a Comment