purbeechhetri
purbeechhetri purbeechhetri
  • 19-03-2021
  • Computers and Technology
contestada

what is output?
a include <iostreom.h>
void sub (float & x)
{ x + =2;
cout <<" \nx="<<x;
}
اے
void main ()
{ clrser ()
float x = 5.8
cout<<" \nx="<<x'
sob (x);
Cout <<"\nx="<<x
getch ();
}​

Respuesta :

tonb
tonb tonb
  • 19-03-2021

Answer:

x=5.8

x=7.8

x=7.8

Explanation:

I repaired the code somewhat (see below).

Since x is passed as a reference variable to the sub function, inside sub() the original variable is modified, so the changed value affects the variable declared in main().

If you would remove the & in sub, this wouldn't happen, and the variable in main would keep its value 5.8.

Ver imagen tonb
Answer Link

Otras preguntas

Line segments can be broken down into what objects?
Evaluate (3n^2 - 14n + 6)/(n^2 + 7n + 2)
What is the legal protection afforded an expression of an idea, such as a song, book, or video game?
For which of the following is heat energy absorbed? Deposition Condensation Sublimation Freezing
The greatest change in terrestrial ecosystems during all of cretaceous was the
A spinner has three sections. The table shows the results of spinning the arrow on the spinner 80 times. What is the experimental probability of the arrow stopp
In the dialogue of the same name euthyphro defines holiness as
What were the effects of cold war challenges in eastern europe and china?
The ________ is a structure in the brain stem that plays a role in sleep, dreaming, left-right body coordination, and arousal.
The area of a parallelogram is 36 cm 2. The height of the parallelogram is 3 centimeters. How long is the base?