Skip to content

Commit

Permalink
Local and Global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Warishayat committed Jan 29, 2024
1 parent eeac979 commit 69ba956
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions LOcalGlobalVariable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include<iostream>
using namespace std;
int globalvariable=20; //global variable
void add()
{
//local variable
int Locavariable=30;
cout<<"The value of the local variable is: "<<Locavariable<<endl;
cout<<"Hellow world"<<endl;
cout<<"The value of global variable is: "<<globalvariable<<endl;
for (int i=1;i<=10;i++)
{

}
// cout<<i<<endl; //Loop variable cant be acces outside the loop...
}
void average(int x,int y) //the paramter inside void average function are formal..
{
int result=(x+y)/2;
cout<<"The value of the average is:"<<result<<endl;
}
int main()
{
//but when i will acess the local variable outside function it will genrate error for me..
add();
// cout<<localvariable<<endl;
//formal paramter and acutsl paramter
int x=20;
int y=40;
average(x,y); //actual paramter ehich is pass through average

}

0 comments on commit 69ba956

Please sign in to comment.