Solution:NIIT/GNIIT Sonugiri0032@gmail.com

Wednesday, January 06, 2016

Global Variable in C++

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

Global Variable in C++
Share:

0 comments:

GNIITSOLUTION GNIIT SOLUTION. Powered by Blogger.

Translate

Blog Archive

Unordered List