Global Variable in C++
Cplusplus, Global Variable declaration, what are the Global Variable in C .
Structure of the Problem Requirements
Global variables are access to the whole program for every function and class . Global variable should be declare when they are too much necessary because they are accessible to the all program so there is a chance that by mistake may be they change.
Source Code
#include<iostream>
using namespace std;
int sum;
int main ()
{
int num1 = 0;
int num2 = 0;
cout<<" Enter Your Number : ";
cin>>num1;
cout<<endl;
cout<<" Enter Your Number : ";
cin>>num2;
sum = num1+num2;
cout<<endl;
cout<<" The Sum of Both Numbers is : " <<sum;
cout<<endl;
}
Output of the Program
0 comments:
Post a Comment