Problem Solving Through C (BCA) 1st Sem Previous Year Solved Question Paper 2022

Practice Mode:
17.

Differentiate between local and global variables.

Explanation

Local Variable:

  1. Local variables are defined within a specific function or block of code.

  2. They have limited scope and can only be accessed and used within the function or block in which they are declared.

Global Variable:

  1. Global variables are defined outside of any function, typically at the beginning of a program.

  2. They have a global scope, which means they can be accessed and modified from any part of the program, including different functions.