Tuesday, 5 January 2016

Local Variables in C++

Local Variables in C++



Structure of the Problem Requirements  
Local variables have some limited access and the are only accessible within the scope of the function or block . Two Separate function could have the same name local variables because they are unknown from outside of the function.
Source Code
#include<iostream>
using namespace std;
int main ()
{
 int num1,num2,num3;                 // declare the variables
 num1 =786, num2 =567;         // initialize the variables
 num3=num1-num2;
 cout<<" \n Num1 is Local variable with values : "<<num1;
 cout<<" \n Num2 is Local variable with values : "<<num2;
 cout<<" \n \n  The Subtraction of these local variables is : "<<num3;
}
Output of the Program
Local Variables in C++


No comments:

Post a Comment