Local and Global variables

A variable is a memory address that can change. Variable is the name of the memory location where data is stored. Once a variable is…