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
Aim: To implement a program for following string operations: Length of String. String Concatenation. Substring (provide start index and length) Find character a

Charity Ball Organizer Many charities support good causes, but one of the difficulties each of them has is organizing their fundraising events. After nearly a semester of C pro

Question: (a) Explain a linked list. (b) Describe the three different types of linked list with the help of diagrams. (c) Give two advantages and two disadvantages

Of course it is C[i] = A[i] + B[i].It was a typing mistake,never mind. You just understand the concept. 27-1 b. for grain-size=1 n=A.length grain-size=1 r=n for

algorithm to find whether a given number is prime number or not? using pseudo code and flowchart


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers

What is difference between require_once (), require(), include()? require() includes and evaluates a specific file, if file isn't found then it shows a Fatal Error. require_

I need vsti program Project Description: Knowledge of vsti programs, and music is a plus, ex: nexus I will input the sounds I just need the interface built Skills required

WAP TO PRINT ANY NAME ON SCREEN 10 TIMES void main () { int a=1; clrscr(); do { printf ("expertsmind\n"); a++; } while (a getch (); }