What are global variables? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

What are global variables?

What are global variables? How are these variable declared and what are the problems associated with using them?

2nd May 2017, 6:54 AM
Aijaz Ahmed
Aijaz Ahmed - avatar
2 Answers
+ 4
Global variables are the variables that can be accessed from anywhere inside the program for example int a=1;//Globally declared variable int main() { int b=2; { int c=3; }//variable c can be used in this scope only cout<<a;//outputs 1 cout<<b;//outputs 2 cout<<c;//gives error return 0 ; } Happy coding...
2nd May 2017, 7:02 AM
Rishabh Agrawal
Rishabh Agrawal - avatar
0
intresting
7th May 2017, 4:47 PM
Hamze Fabio
Hamze Fabio - avatar