Data Type:
Data type defines a type of a variable or a value. The data is stored in a variable is according to its data type otherwise, it will generate an error.There are main data types:
- int (integer)
- char (character)
- float
- Boolean
int data type:
int datatype is used to store the integers. It allows a variable to store an integer value. Both negative and positive numbers can be assigned to int datatype but it does not support floating values.Example:
int roll_no = 5;int a=-18;
char data type:
char data type is used to store a character. One character will use a 1 bit of memory.A character is enclosed in single-quotation [‘ ‘].
Example:
char s = ’a’;float data type:
float datatype is used to store a numeric value with a fraction or can point value. It allows both negative and positive numbers as well as floating values.Example:
float height = 5.5647;float radius = 2.8931;
No comments:
Post a Comment