WHAT ARE DATATYPES & VARIABLES


WHAT ARE DATATYPES & VARIABLES ?

DEFINITION OF DATATYPE :

A Datatype is a predefined set of data items. A classification that specifies which type of value a variable has and what type of mathematical, relational & logical operations can be applied to it without causing an error.

TYPES OF DATATYPES :

1. Integer :

An integer is used for storing a numeric value i.e 0,1,2,3,4,....

Example :

      int a = 5;
(where a is a variable) 

2.String:

A string can store Alphabets , numbers , special characters (! @ ) .
String must be written in double quotation.

Example:

     string web="WORLD TRUE SIGHT";

3.Double:

Double is same as integer i.e it stores numeric data . The only difference is it stores decimal numbers. 
        

Example:

double num=3.22245d;

4. Float:

Float is same as DOUBLE but it stores roundoff decimal numeric data.

Example:

float num = 3.23f ;

5.Character:

Char stores characters only i-e (a , b , c, .... ) . Character must be written in single quotation.

Example:

char ch = 'a' ;

6.Boolean:

Boolean is use to store only TRUE & FALSE . Bool is used to check  conditions. 

Example:

 bool check = "True"; 

WHAT ARE VARIABLES ?

In Programming variables are used to store data . 
  • A variable name must be meaningful .
  •  A variable never start with a digit but we can use the digit in the end or in between . For example : 
a1   
a1b 
 1a. 
  • We can't use spacing between variables.
abc  
ab     c 

  • Only a special character ( _ ) is used in between , start and end of variable.
_a 
a_ 
a_a  ✅ 

INITIALIZING A VARIABLE:
                    
                        int age ;
                        string name;
                        float num ;
                        double num2;
                        
ASSIGNING A VARIABLE: 

               Assigning a variable means giving the variable a proper value.
e.g :
               int age= 2;
               string name ="WTS";
               float num=2.34f;
               double num2=2.3333d; 

--------------------********--------------------************---------
Hope this documentation on DATATYPES & VARIABLE is helpful for you . If you have any question regarding datatypes and variables , you are free to ask in the comment section... 

Post a Comment

0 Comments