Thursday 11 September 2014

Program No.2
Write a program that declare two variables and then add them and show their result.



OUTPUT:-
In above program i declare 2 variables a and b assign 6 to a and 7 to b and then declare another variable named sum and assign 0 to it.Then i add a and b and store their result in sum through (=)
operator.This operator is used to assign a value to variable its called assignment operator.And then i show the value of sum which is 13.

NOTE;-
If we don't assign 0 to sum it give a garbage value in the result because at the time of its declaration its value is garbage mean's their is no value stored in it that is why first we will store 0 in it and then store the result of a and b.

No comments:

Post a Comment