What is the difference between global variables and local variables? Give an example to illustrate the same. (C++)

57 Views|Posted 9 years ago
Asked by Arisha Nusrat
1 Answer
Rishi Broto Chakraborty
9 years ago
Hello Arisha, Global variables can be accessed by any function within the class / package, where it is declared. Local variables, on the other hand, can be accessed only within a particular function where it has been declared. E.g.: int a=10; int disp() {cout a; //displays value 10 int b=5; cout

...Read more

Thumbs Up IconUpvote Thumbs Down Icon

Taking an Exam? Selecting a College?

Get authentic answers from experts, students and alumni that you won't find anywhere else.

On Shiksha, get access to

66K
Colleges
|
1.2K
Exams
|
6.9L
Reviews
|
1.8M
Answers

Share Your College Life Experience

Didn't find the answer you were looking for?

Search from Shiksha's 1 lakh+ Topics

or

Ask Current Students, Alumni & our Experts

Have a question related to your career & education?

or

See what others like you are asking & answering