What is the difference between Local & Global Variables?

16. What is the difference between Local & Global Variables?

  1. Variables in an outer block are defined as local variables since they cannot be accessed from the outside whereas the innermost block declares global variables.
  2. Variables in an inner block are defined as global variables since they cannot be accessed from the outside whereas the outermost block declares local variables.
  3. Variables in an outer block are defined as global variables since they can be accessed from the outside and the innermost block also declares global variables.
  4. Variables in an inner block are defined as local variables since they cannot be accessed from the outside whereas the outermost block declares global variables.

Answer: D) Variables in an inner block are defined as local variables since they cannot be accessed from the outside whereas the outermost block declares global variables.

Explanation:

Variables in an inner block are defined as local variables since they cannot be accessed from the outside whereas the outermost block declares global variables.


Comments and Discussions!





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.