Global variables could be access to the whole program for every function and class. Global variable should only declare when they are too much necessary because these are accessible to the all program so there is a chance that anyone can change them.
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; }
0 comments:
Post a Comment