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 computes the cost of a long distance call. The cost of the call is determined according to the following rate schedules. a. A call made between 8:00 AM and


what is the purpose of pointer ? what is the syntax? how it works?

Compiler Design - Limit In The Method Instructions



make a marksheet of 2 student with 5 subject

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Record separation problem Let us assume that a particular database program manages a simple mailing list which consists of one record for each person on the list, and a number of f

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of t