Create program to prints out the value of a variable, C/C++ Programming

Here is a short program. It prints out the value of a variable "x". Ernie and Bert disagree about what will be printed: Ernie says, the value gets changed in "changeX" so it will print "7", and Bert says, no, when the function exits the changes get reversed and the value goes back to "5". Explain who is correct and why.

int x = 5;

void draw()

{

   changeX();

   print(x);

}

voidchangeX()

{

   int x = 7;

}

 

 

Posted Date: 3/29/2013 2:03:11 AM | Location : United States







Related Discussions:- Create program to prints out the value of a variable, Assignment Help, Ask Question on Create program to prints out the value of a variable, Get Answer, Expert's Help, Create program to prints out the value of a variable Discussions

Write discussion on Create program to prints out the value of a variable
Your posts are moderated
Related Questions
A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

Implement a menu driven real estate catalogue system that allows users to perform various catalogue maintenance and search tasks.  You are only allowed to use the C programming la

Define Pure Virtual Function? Why & when it is used?

What is inheritance? Class, the vehicle, which is used to execute object-oriented concepts in C++, has given a new dimension to this idea of reusability. Many vendors now offer

Ba s i c r u l e s o f C + + p r o g r a m : ·     I t m u s t h a v e o n l y o n e m a i n f u n c ti o n ·

A: No. (Excluding if you have an old compiler, you might have to force the new operator to throw an exception if it runs out of memory.) This turns out to be a real pain to alwa

Templates permit to create generic functions that admit any data type as parameters and return value without having to overload the function with all the possible data types. Until

Need help with C network program

Write a C++ program with header and source files to store street addresses using the Doubly Linked List ADT. Modify the Node class from Lab Assignment 3 so that it becomes a node i

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b