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
Holly created a professional development plan to explore how she could advance from her entry-level position to the next step in
Sunny_sXe [5.5K]
A.) Ask a colleague for advice work life balance
3 0
3 years ago
Read 2 more answers
What is displayed in the alert dialog box after the following code is executed? var scores = [70, 20, 35, 15]; scores[scores.len
kvv77 [185]

Answer:

The scores array: 70,20,35,15,40

Explanation:

I will explain the code line by line:

var scores = [70, 20, 35, 15];  

The above statement declares and assigns values to an array named scores

scores[scores.length] = 40;  

The above statement uses length to set the length of the scores array. It sets the last element of the scores array to 40. So this means 40 is set as the last element of scores.

scores.length returns the length of the scores array i.e. 4 as there are 4 elements in scores array 70,20,35,15

So the statement becomes:

scores[4] = 40;

This assigns value 40 to the 4th index of the scores array. Do not confuse 4th index with 4th element of the array because array element location starts from 0. So scores[4] does not mean 4th element but scores[4] means 4th index position of scores array. This makes 5th element of scores. So set the element 40 as 5th element at 4th index of scores.

alert("The scores array: " + scores);

This displays an alert box with the following message:

The scores array: 70,20,35,15,40

4 0
3 years ago
What are some of the things people try to do on social media when they can use
Andrej [43]

Answer: catfishing

Explanation:

They hide behind a screen and pretend to be and look like someone they're not by putting up fake pictures etc.

5 0
3 years ago
The following equations estimate the calories burned when exercising (source): Men: Calories = ( (Age x 0.2017) — (Weight x 0.09
sdas [7]

Answer:

// program in Python.

#function to calaculate calories burned

def cal_burned(u_age, u_weight, heart_rate, time, gen):

   #variable

   cal = 0.0

   #for men

   if gen == 'm':

       cal = ((u_age * 0.2017) - (u_weight * 0.09036) + (heart_rate * 0.6309) - 55.0969) * time / 4.184

   #for women

   elif gen == 'f':

       cal = ((u_age * 0.074) - (u_weight * 0.05741) + (heart_rate * 0.4472) - 20.4022) * time / 4.184

#return calories burned

   return cal

#driver function

def main():

   #read age

   u_age=int(input('Enter age (years):'))

   #read weight

   u_weight=float(input('Enter weight (pounds):'))

   #read heart rate

   heart_rate=float(input('Enter heart rate (beats per minute):'))

   #read time

   time = int(input('Enter time (minutes):'))

#call function for Men

   calories_man=cal_burned(u_age,u_weight,heart_rate,time,'m')

#call function for women

   calories_women=cal_burned(u_age,u_weight,heart_rate,time,'f')

#print calories burned for Men

   print('Men: {:.2f} calories'.format(calories_man))

#print calories burned for women

   print('Men: {:.2f} calories'.format(calories_women))

#call main function

main()

Explanation:

Read age, weight, heart rate and time from user.Then call the function cal_burned() with all the input and a character parameter for men.This function will calculate  and return the total calories burned by the men.Similarly call the function again for women, Then it will return the calories burned by women.Print the calories burned by men and women.

Output:

Enter age (years):25                                                                                                      

Enter weight (pounds):180                                                                                                  

Enter heart rate (beats per minute):145                                                                                    

Enter time (minutes):50                                                                                                    

Men: 300.68 calories                                                                                                      

Men: 429.71 calories  

8 0
4 years ago
Rate these 3 fnaf characters from 1-3 tell me who you find the scariest as well
Brut [27]

Answer:

Golden Freddy is the scariest in my opinion

4 0
3 years ago
Read 2 more answers
Other questions:
  • What color does Sam obtain when he mixes white with a color? Sam is painting a landscape and needs to paint the sky light blue.
    9·2 answers
  • A virus enters a computer or network _____.
    13·1 answer
  • A palindrome is a word or phrase that reads the same both backward and forward. The word ""racecar"" is an example. Create an al
    15·1 answer
  • There are n coins, each showing either heads or tails. We would like all the coins to show the same face. What is the minimum nu
    6·1 answer
  • In the Mouse Properties window, you can?
    8·1 answer
  • Write a program that prompts the user to enter the minutes (e.g., 1 billion), and displays the number of years and days for the
    7·1 answer
  • The following are part of characteristics of a software requirement specification.
    6·1 answer
  • Which device do engineers use to drive a system of gears?
    15·2 answers
  • What should be taken into consideration when determining which critical information should be protected?
    11·1 answer
  • Importance of software in computer​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!