What is the output of the loop as it is written

Assignment Help C/C++ Programming
Reference no: EM13339031

The loop shown below has been written by an inexperienced C/C++ programmer. The behavior of the loop is not correctly represented by the formatting.

int n = 10;
while (n > 0)
n /= 2;
cout << n * n << endl;

a. What is the output of the loop as it is written?

b. Correct the syntax of the loop so that the logic of the corrected loop corresponds to the formatting of the original loop. What is the output of the corrected loop?

c. Correct the formatting of the (original) loop so that the new format reflects the logical behavior of the original loop.

Reference no: EM13339031

Questions Cloud

Evaluate the effectiveness of a new drug to prevent preterm : A clinical trial is conducted to evaluate the effectiveness of a new drug to prevent preterm delivery.
What is the output of this code fragment as it is written : In the code fragment below, the programmer has almost certainly made an error in the first line of the conditional statement.
How far does the person travel : A person takes a trip, driving with a constant speed 90 km/h except for a 15 minute rest stop. If the person's average speed is 45 km/h, how far does the person travel
Why are academic health centers are vital : Why are academic health centers are vital to research and technology? give 3 examples
What is the output of the loop as it is written : Correct the syntax of the loop so that the logic of the corrected loop corresponds to the formatting of the original loop. What is the output of the corrected loop?
Discuss the potential negative impact of a dominant culture : To prepare: Review "Working With Immigrants and Refugees: The Case of Aaron."
Write a function named digit_name : Write a function named "digit_name" that takes an integer argument in the range from 1 to 9 , inclusive, and prints the English name for that integer on the computer screen.
Write a function named is_prime : Write a function named "is_prime" that takes a positive integer argument and returns as its value the integer 1 if the argument is prime and returns the integer 0 otherwise.
Find the terminal velocity of the sled : A test sled has a mass of 400 kg and is acted on by a thrust force of 200,000 N. It also experiences a viscous drag of 1600•V where V is the velocity. Find the 'terminal velocity' of the sled

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Develop a simple poker game

Develop a simple poker game

  Write a recursive definition in sml to reverse

Write a recursive definition in SML to reverse a list of elements and multiply all elements with 2.

  Initialize an array and fill the array with the gpa values.

Write a program in java that asks user input (using a loop) for name of 10 student and the corresponding grade point averages (GPAs). Initialize an array and fill the array with the GPA values.

  Write function named enough that takes one integer argument

Write a function named "enough" that takes one integer argument, call it "goal" and returns as its value the smallest positive integer n for which 1+2+3+. . . +n is at least equal to goal .

  Program to tell you how many months it will take to pay off

write a program to tell you how many months it will take to pay off any loan, as well as the total amount of interest paid over the life of the loan.

  Write a program that asks the user to enter the names of 3

Write a program that asks the user to enter the names of three salesmen. The program should thenaccept the sales produced for salesman for each quarter of the year. Display the name, and the totalsales amount, of each salesman.

  Create a calling module name and parameters

Create a calling module name and parameters for the following. (Remember that the asterisk before the parameter name indicates a call-by-reference parameter.

  Create an employee class

Create an employee class, including two data: an employee number (type int ) and the employee's compensation (in dollars; type float). The member data should comprise an int for storing the employee number and a float for storing the employee's co..

  Uml diagram of all the classes

Speaking of converting into the correct object-type, the goal of the factory is to abstract away object creation.

  Operating system and cpu scheduling

Operating System and CPU Scheduling

  C program that compare the time required

Write a C program that compare the time required to compute the product of two 10,000 x 10,000 matrices with and without optimization for locality.

  Write a program that will read in 2 numbers per line

1.Write a program that will read in 2 numbers per line, and print the sum. You program should work for any number of lines of data.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd