Example of function - c program, 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/20/2013 5:23:45 AM | Location : United States







Related Discussions:- Example of function - c program, Assignment Help, Ask Question on Example of function - c program, Get Answer, Expert's Help, Example of function - c program Discussions

Write discussion on Example of function - c program
Your posts are moderated
Related Questions
Overloading Binary Operators Using Friend Function class SI {float i,p,n,r,a; public: SI(){}; SI(int gp,int gn, int gr); void putdata(void); friend SI operato

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

#write a multilevel c++ program to take marks of 3 subjects and calculate percentage and display it

solve for radius(R) of a circle of its area is to be inputted by a user. also display compute the circle diameter hint: area= pir21 pi=2.1416

A: Use references when you can use, and use pointers when you have to. References are generally preferred over pointers whenever you don't require "reseating". Usually this mean

Write the statements which are used to connect PHP with MySQL? Statements which can be used to connect PHP with MySQL is: $conn = mysql_connect('localhost'); echo $co

program coding for the conversion of string to a palindrome

Write a program of constructors and destructors Make a class drugs having encapsulated data for medicine name, whether solid or liquid, price and purpose of use. From this clas

In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc

a program that declares and prompts the user to enter two integer and performs the five arithmetic operations