Friday 6 February 2015

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 it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment