1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
madreJ [45]
2 years ago
7

What is the output of the following program? #include using namespace std; void doSomething(int&); int main() { int x = 2; c

out << x << endl; doSomething(x); cout << x << endl; return 0; } void doSomething(int& num) { num = 0; cout << num << endl; }
Computers and Technology
1 answer:
Whitepunk [10]2 years ago
4 0

Answer:

The output will be as following:-

2

0

0

Explanation:

The function doSomething accepts the argument as reference.So whatever changes are made in the function to the argument the changes will be reflected onto the original arguments.

First the value of x is 2.Hence  2 is printed first.

Then function doSomething is called that changes the value of x from 2 to 0 and then prints it.Hence 0 is printed in the newline.

Then in the main function x is printed again the function changed it's value so 0 is printed.

You might be interested in
Evaluating how current, credible, and unbiased a source is ensures:
Tanya [424]

The answer is

A. your information is more accurate and useful

I hope it helps you. Please mark me brainliest answer.

6 0
3 years ago
Http://www.alegrium.com/sgi/2/eibder
Flura [38]

Answer:

so what is this uhhhhhhhhhh

7 0
2 years ago
a.Write a Python function sum_1k(M) that returns the sum푠푠= ∑1푘푘푀푀푘푘=1b.Compute s for M = 3 by hand and write
stealth61 [152]

Answer:

def sum_1k(M):

   s = 0

   for k in range(1, M+1):

       s = s + 1.0/k

   return s

def test_sum_1k():

   expected_value = 1.0+1.0/2+1.0/3

   computed_value = sum_1k(3)

   if expected_value == computed_value:

       print("Test is successful")

   else:

       print("Test is NOT successful")

test_sum_1k()

Explanation:

It seems the hidden part is a summation (sigma) notation that goes from 1 to M with 1/k.

- Inside the <em>sum_1k(M)</em>, iterate from 1 to M and calculate-return the sum of the expression.

- Inside the <em>test_sum_1k(),</em> calculate the <em>expected_value,</em> refers to the value that is calculated by hand and <em>computed_value,</em> refers to the value that is the result of the <em>sum_1k(3). </em>Then, compare the values and print the appropriate message

- Call the <em>test_sum_1k()</em> to see the result

8 0
2 years ago
Write the pseudocode for this flowchart
MrMuchimi

Answer:

Explanation:

class TimeToSleep() {

  main bunch of stuff (string argos) {

       int age;

       string comedy;

       bool guess;

        public bool imTheMasterMethod() {

           guess = true;

           while (guess) {

              comedy = "You forgot to put the flowchart, you meathead!";

              println(comedy);

               

                scan("%d", &age);

                if (age < 18) {

                    println("Go to sleep kiddo!");

                }

           }

        }

   }

}

       

6 0
2 years ago
Will somebody help me???? ANYBODY?? PLZZZZZZZZZZZZ
romanna [79]
I've never seen that third syntax. If it's legit, it probably does the same as I and II, which are the same.
6 0
3 years ago
Other questions:
  • How many bit does four gigabyte has
    8·2 answers
  • What error occurs when you perform an illegal math operation such as divide by zero
    13·1 answer
  • Hey I don’t have a question I’m just testing something on this app
    6·2 answers
  • How do you turn on the Track Changes feature in a word-processing document?
    12·1 answer
  • The _____ handles the instructions for your computer to start up before the operating system is loaded.
    10·1 answer
  • Kevin gets a call from a user who is trying to install a new piece of software. The user doesn’t have administrative rights, so
    10·1 answer
  • Please help with this
    8·1 answer
  • MR. Tom asked her students could they plant a flower and bring it to class. Sarah brought his flower and said it was a rose. Jam
    6·1 answer
  • When creating an HTML document, what do we use to set aside space for content?
    14·1 answer
  • Patricia Works in a coffee shop and manages the inventory of items.for each item she needs to recover the quantity in stock and
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!