Friday, 24 March 2017

Constants And Variables

Variables is a location where values are store.When we make our program we use data types for storing different types of values in our program and variable uses for handling the values.

                                                             Int a = 9;

Int is a data type and (a) is variable name and 9 is the value which store in variable (a).When we need to use 9 in our program than we use a instead of 9.

What is the difference between a constant and a variable?

The difference between variables and constants is that value of variables may can change during the execution of program at any time but constants can never change their value.Constants can be very useful, Pi for instance is a good example to declare as a constant.

No comments:

Post a Comment