Create program to prints out the value of a variable, C/C++ Programming

Assignment Help:

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;

}

 

 


Related Discussions:- Create program to prints out the value of a variable

Operation on array - c program, Operation on array: void Array::add( O...

Operation on array: void Array::add( Object& toAdd ) {     lastElementIndex++;     while( ptrAt( lastElementIndex ) != ZERO &&            lastElementIndex

Advanced error checking and structures, It is standard on functions to prov...

It is standard on functions to provide some indication that the function has succeeded in its operation. Consider the Scanf function:     scanf("%d",&number1);   If the functio

Calculate the area and circumference of a circle , Write a program which in...

Write a program which incorporates a function named compute and which is used to calculate the area and circumference of a circle. Use the main function for inputs and outputs.

Lexicographic permutation, Ask questioGiven an integer n and a permutation ...

Ask questioGiven 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. I

Looping, Write a programme to display the patern.. A A B A C B A B C...

Write a programme to display the patern.. A A B A C B A B C A B A A

What are arrays, What are Arrays? Numerous applications require the pro...

What are Arrays? Numerous applications require the processing of multiple data items that have identical characteristics. In such circumstances it is frequently convenient to p

Write code to implement constructor, Study the following  class diagram, ad...

Study the following  class diagram, additional information  and answer  the  questions that follow: MovieTicket movieName: string TicketPrice: doub

Define namespace in c++, It is a feature in C++ to reduce name collisions i...

It is a feature in C++ to reduce name collisions in the global name space. This namespace keyword assigns a separate name to a library that allows other libraries to use the simila

Gross pay, Develop a C++ program that uses a while to determine the gross p...

Develop a C++ program that uses a while to determine the gross pay (in Dollars) for each of several employees. The company pays “straight-time” for the first 40 hours worked by eac

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd