blogger Indonesia

Follow judhyns blog

Chapter 2: Data Types THE BUILT-IN DATA TYPES IN C

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.

Program

// the program gives maximum and minimum values of data type
#include main() { int i,j ;// A i = 1; while (i > 0) { j = i; i++; }
printf ("рдеे maximum value of integer is
%d\n",j);
printf ("the value of integer after overflow is%d\n",i); }

Explanation

  1. In this program there are two variables, i and j, of the type integer, which is declared in statement A.

  2. The variables should be declared in the declaration section at the beginning of the block.

  3. If you use variables without declaring them, the compiler returns an error.

Points to Remember

  1. C supports various data types such as float, int, char, etc., for storing data.

  2. The variables should be declared by specifying the data type.

  3. 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:

feed

PR Check

activesearchresults

judhyn's blog

 

http://www.judhyn.blogspot.com | |