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
Write a Program that illustrate Command Line Parameters? main(int argc, char *argv[]) { int i; for(i = 0; i printf("arg %d: %s\n", i, argv[i]); return 0; }

main() { int a[5]={1,3,6,7,0}; int *b; b=&a[2]; } The value of b[-1] is

Make QtAV Videoplayer simple integrateable for Qt Applications Project Description: I'm preparing an application for Windows and Mac using QtCreator. I want a videoplayer

Write a program to calculate the total resistance of a series or parallel circuit. The maximum number of resistors is two.   We need to decide whether the user wants the to

How can I handle a constructor that fails?

This project simulates an application called tracker for the Department of Transportation (DOT) in which highway traffic data is accumulated in real time using various sensing equi

Define the following Window class : - integer  data members, width and height - a constructor  that accepts two integer  parameters  (width followed by height) and uses them to ini

Based on the automobile's model year and weight, the city of Cebu determines the car's weight class and registration fee using the following schedule: Model Year Registration

Verifone pos offline mod vx670 Project Description: I want a programmer who will build custom application for Offline VX670 to collect and save info+pin 1) Press the am

Abstract array - c program: AbstractArray::AbstractArray( int anUpper, int aLower, sizeType aDelta ) {     PRECONDITION( anUpper >= aLower );     lastElementIndex = a