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
Lady_Fox [76]
3 years ago
9

What will the following code display? #include using namespace std; void doSomething(int); int main() { int x{2}; cout <<

x << '\n'; doSomething(x); cout << x << '\n'; return 0; } void doSomething(int num) { num = 0; cout << num << '\n';
Computers and Technology
1 answer:
Leno4ka [110]3 years ago
8 0

Answer:

The code will display the following on the screen:-

2

0

2

Explanation:

The output is like this because x{2} assigns the value 2 to the integer x.First the value of x is printed on the screen that is 2 and that newline is used to go to the next line.After that function is called doSomething with x passed as the argument. doSomething function assigns the value zero to the variable passed and prints it on the screen.So the next line is 0.Since x is passed by value so no changes will appear in the original argument.Hence the last line printed is 2.

You might be interested in
Assume that you have 22 slices of pizza and 7 friends that are going to share it (you've already eaten). There's been some argum
xz_007 [3.2K]

Answer:

In Python:

numberOfWholeSlices = int(22/7)

print(numberOfWholeSlices )

Explanation:

For each friend to get a whole number of slices, we need to make use of the int function to get the integer result when the number of slices is divided by the number of people.

So, the number of slice is: 22/7

In python, the expression when assigned to numberOfWholeSlices  is:

numberOfWholeSlices = int(22/7)

Next, is to print the calculated number of slices

print(numberOfWholeSlices )

4 0
3 years ago
g Write a program that prompts the user for an integer n between 1 and 100. If the number is outside the range, it prints an err
grin007 [14]

Answer:

The cpp program is given below.

#include<iostream>

#include<iomanip>

using namespace std;

int main() {

   

   // variables declared

   int n;

   int sum=0;

   float avg;

   

   do

   {

       // user input taken for number    

       cout<< "Enter a number between 1 and 100 (inclusive): ";

       cin>>n;

       

       if(n<1 || n>100)

           cout<<" Number is out of range. Enter valid number."<<endl;

       

   }while(n<1 || n>100);

   

   cout<<" "<<endl;

   

   // printing even numbers between num and 50  

   for(int num=1; num<=n; num++)

   {

       sum = sum + num;

   }

   

   avg = sum/n;

   

   // displaying sum and average

   cout<<"Sum of numbers between 1 and "<<n<<" is "<<sum<<endl;

   cout<<"Average of numbers between 1 and "<<n<<" is ";

   printf("%.2f", avg);

   

       return 0;

}

OUTPUT

Enter a number between 1 and 100 (inclusive): 123

Number is out of range. Enter valid number.

Enter a number between 1 and 100 (inclusive): 56

 

Sum of numbers between 1 and 56 is 1596

Average of numbers between 1 and 56 is 28.00

Explanation:

The program is explained below.

1. Two integer variables are declared to hold the number, n, and to hold the sum of numbers from 1 to n, sum. The variable sum is initialized to 0.

2. One float variable, avg, is declared to hold average of numbers from 1 to n.

3. User input is taken for n inside do-while loop. The loop executes till user enters value between 1 and 100. Otherwise, error message is printed.

4. The for loop executes over variable num, which runs from 1 to user-entered value of n.

5. Inside for loop, all the values of num are added to sum.

sum = sum + num;

6. Outside for loop, average is computed and stored in avg.

avg = sum/n;

7. The average is printed with two numbers after decimal using the following code.

printf("%.2f", avg);

8. The program ends with return statement.

9. All the code is written inside main() and no classes are involved.

3 0
3 years ago
Can someone help me with this one
MAVERICK [17]

Answer:

true

Explanation:

it is because when someone feels better about something that means that their self esteem is building up

8 0
4 years ago
Read 2 more answers
Use the following to calculate the acid-test ratio. (Round your answer to two decimal places.) Cash: $100,000 Short-term investm
uysha [10]

Answer: 0.48

Explanation:

The acid test ratio will be calculated as:

Cash = $100,000

Add: Short term investments = $17,000

Add: Net Current Receivables = $250,000

Total Assets = $367,000

/ Total Current Liabilities = $760,000

Acid Test Ratio will now be:

= Total Assets / Total Liabilities

= $367000/$760000.

= 0.48

Therefore, the acid test ratio is 0.48.

5 0
3 years ago
How does technology improve convenience, but impact our privacy?
Aneli [31]

Answer:

Convenience of tech- Easier to shop,learn,meet new people

Impacts privacy- technology impacts your privacy because many people have their identity, credit card numbers, emails, etc.

Explanation:

~ItsOniiSama<3

Hope this helps

3 0
3 years ago
Other questions:
  • What message would you have gotten if your computer became infected with the elk cloner virus?
    7·1 answer
  • Time Conversion C++: Given a time in -hour AM/PM format, convert it to military (24-hour) time.
    9·1 answer
  • How to convert mkv to avi without losing quality?
    14·1 answer
  • If you Owned a business, what part of Microsoft Office would you use the most and why, which would you use the least and why, an
    14·1 answer
  • By
    7·1 answer
  • What pc games do you all play?
    14·2 answers
  • Neview of related literature happens in two wayo (1) Traditional and
    6·1 answer
  • A major retailer wants to enhance their customer experience and reduce losses
    9·1 answer
  • SOMEONE PLEASE HELP ME OUT WITH!!!!!
    14·2 answers
  • A company is concerned that hackers may gain access to its computer system or that it may be
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!