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

Which of the following statements is true? All multicellular organisms have circulatory systems. All multicellular organisms have skeletal systems. All multi
Algebra help pleaseeee
The English social critic, writer, artist and theorist who inspired the philosophy of the arts and crafts movement challenged orthodoxy around the Renaissance a
Describe the earths lithosphere include the depths and different parts
what is ⅞ ÷ (⅔ (⅓) )=
HELP ME ! Which of the following statements is FALSE? a. After the Galveston Hurricane of 1900 the city built a 17-foot sea wall to protect Galveston from futu
7. What kind of government was created by the Articles of Confederation?
What did the mother say to victor one telling him about Elizabeth?
If the discriminant is less than zero than the equation has ______________ solutions. PLEASE HELP!!
- What effect does sweating have on body temperature?