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]
3 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]3 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
2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you
Lilit [14]

Explanation:

Number of characters: 46

String with no whitespace: Theonlythingwehavetofearisfearitself.

########################################################

def get_num_of_characters(inputStr):

   count = 0

   for i in range(0,len(inputStr)):

       count = count + 1

   #count = len(inputStr)

   return count

def output_without_whitespace(inputStr):

   #statement = statement.strip()

   statement2 = ' '

   for i in range(0,len(inputStr)):

        if(inputStr[i] == ' '):

           statement2 = statement2

       else:

           statement2 = statement2 + inputStr[i]

       

   inputStr = inputStr.replace(" ", "")

   return statement2

inputStr = input('Enter a sentence or phrase: ')

print()

print('You entered:', inputStr)

num = get_num_of_characters(inputStr)

print()

print('Number of characters:', num)

print('String with no whitespace:',output_without_whitespace(inputStr))

#if __name__ == '__main__':

   # Think I'm supposed to use this if statement

########################################################

'''ERROR MESSAGE WHEN RUNNING TEST

Unit test

0/1

Tests that get_num_of_characters() returns 46 for "The only thing we have to fear is fear itself."

Your output

Enter a sentence or phrase: Traceback (most recent call last):

 File "zyLabsUnitTestRunner.py", line 4, in <module>

   from zyLabsUnitTest import test_passed

 File "/home/runner/local/unit_test_student_code/zyLabsUnitTest.py", line 1, in <module>

   from main import get_num_of_characters

 File "/home/runner/local/unit_test_student_code/main.py", line 19, in <module>

   inputStr = input('Enter a sentence or phrase: ')

EOFError: EOF when reading a line'''

6 0
3 years ago
Diagnosing is solving the problem, and trouble shooting is figuring out what the problem is.
exis [7]
False its the opposite
3 0
3 years ago
What statement best decribes the relashionship bewteen science and technoligy?
butalik [34]
The correct answer would be A.
7 0
3 years ago
Read 2 more answers
Which of the following describes the difference in light intensity between the brightest white and the darkest black that can be
Y_Kistochka [10]

Answer:

a. Contrast ratio

Explanation:

According to my research on LCD technology, I can say that based on the information provided within the question the term being described by the question is called Contrast Ratio. This is used in all TV's and monitors, since it controls the blacks and white color gradient of the images on the TV's and monitors.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

8 0
3 years ago
Which device allows you to convert sounds into digital format to be used on the computer​
Anton [14]
The correct anwser is ADC
8 0
3 years ago
Other questions:
  • when seeking information on the on the internet about a variety of subjects the most useful place to look would be?
    13·1 answer
  • The business case for using grid computing involves all of the following except: speed of computation. cost savings. agility. in
    5·1 answer
  • Digital certificates can be used for each of these EXCEPT _____. A. to encrypt channels to provide secure communication between
    13·1 answer
  • Who is hurt by piracy
    10·1 answer
  • Write a program that receives an character and displays its Unicode. Here is a sample run: Enter an character: E The Unicode for
    8·1 answer
  • A system administrator is selecting an operating system for use by the company’s research and development team. The team require
    15·1 answer
  • Did anyone else remember that Unus Annus is gone? I started crying when I remembered.... Momento Mori my friends.... Momento Mor
    9·2 answers
  • Working with do-while loop
    9·1 answer
  • Which step in the software development life cycle analyzes the scope of work?
    6·1 answer
  • Visit on social networking site and look for the site's privacy policy.The link is typically found at the bottom of the page and
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!