Wednesday, 21 November 2012

Integers in C Sharp

As we know variables can store text as well as numbers.There are many way to store numbers like numbers can be stored in Variables called Floats Doubles and Integers.In this lesson we are going to learn Integers in detail.

Integers in C Sharp:

                             Integers are whole numbers like 1,2,3 or 450 , 6809 they don't contain any dismal point. 
How to Create an Integer Variable:
To create an integer simply type ' int ' and then name of the variable for example if you want to create an integer variable  ' Age ' you need to type the following code  

int Age;

How to assign a value to an Integer Variable: 

                                                                    To assign a value to an integer you need to type the name of integer then " = " equal sign and then the value in whole numbers,For example if you want to assign  integer "Age" a value of  " 22 " you have to write code in the following way.

Age = 22;

How to out put  a value from an Integer Variable:

                                                                                                      To out put a value from an integer variable you simple need to write the following code 

Console.WriteLine( Age );

How to use the value stored in  an Integer Variable:

                                                                                                           If you want to use the value of integer            take the following example.

     int Age_of_Father = Age + 10;

Console.WriteLine( Age_of_Father );

No comments:

Post a Comment