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
Reference Oddities A reference variable can demote to any integer variable, be it in an array or a member variable from structure or class. Reference variables can demote to co

What is Union? Intimately associated with the structure is the union which as well contains multiple members. Unlike a structure but the members of a union share the same stora

C program to demonstrate Pointer to string: void main() {                 int a;                 char str[]="hello how are you?",*ptr_str;                 ptr_str=&

Define Generic Bitwise Operations? Bitwise operators only work on an incomplete number of types int and char. It turns out there's above one kind of int. In particular there's

6#666#665533999 where # is used as space.output is monkey

programing code on board coloring in clanguage

A virtual function permits derived classes to replace the implementation given by the base class. The compiler makes sure the replacement is always known as whenever the object in

C program to demonstrate call by reference: void disp(int *,int*,int*,int*); void main() {                 int a=2,b=3, sum,mul;                 printf("Enter 1st n

This is what I need help with. "Create a program creates an interface allowing the user to select from some other programs I have made one being a money converter and the other ca

Explain the Function Prototype? The Functions must be declared before they are used, ANSI C provides for the new function declaration syntax called as the function prototype,