CrazyEngineers
  • Hey ppl,

    This is a good question asked to my friend in his interview. They asked him to make a simple stack program. He made it using array and declaring it globally so each function could access it easily. But they told him, its not good to use global variables in program. And according to him this might be the reason he didnt get selected. Can anyone throw some more light on this????
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manashree Thokal

    MemberAug 8, 2011

    Global variables, though convenient to access should not much put into practice. This very advantage can as well be a disadvantage. As it can be accessed by any function, there could be conflicting values as they are modified. It better with local variables where there scope is limited, hence can be managed efficiently.
    Are you sure? This action cannot be undone.
    Cancel
  • vik001ind

    MemberAug 18, 2011

    There is no such disadvantage of using global variables unless you know where to use local & global variables. Global variables are stored in data segment whereas local variables are stored in stack. Creating global variable saves you from passing varibles & saving stack memory. Also creatind too many local variables are not recommended.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register