Write a while loop that prints A. All squares less than n. For example, if n is 100, print 0 1 4 9 16 25 36 49 64 81. B. All positive numbers that are divisible by 10 and less than n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90 C. All powers of two less than n. For example, if n is 100, print 1 2 4 8 16 32 64.

1 answer
Question:

Write a while loop that prints
A. All squares less than n. For example, if n is 100, print 0 1 4 9 16 25 36 49 64 81.
B. All positive numbers that are divisible by 10 and less than n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90
C. All powers of two less than n. For example, if n is 100, print 1 2 4 8 16 32 64.

Answers

Answer:The program to this question as follows:Program:#include <iostream> //defining header fileusing namespace std; int main() //defining main method{int squ=0,n=0; //defining variablecout<<"Square between 0 to 100 :"; //messagewhile(n<100) //loop for calculate Square{n=squ*squ; //holing value in n variablecout<<n<<" "; //print Squaresqu++; //increment value by 1}cout<<endl; //for new linen=1; //change the value of ncout<<"Positive number, which is divisible by 10: "; //messagewhile (n< 100) //loop for check condition{if(n%10==0) //check value is divisible by 10{cout<<n<<" ";//print value }n++; //increment value of n by 1} cout<<endl; //for new linecout<<"Powers of two less than n: "; //messagen=1; //holing value in nwhile (n< 100) //loop for check condition{cout<<n<<" ";//print valuen=n*2; //calculate value}return 0;}Output:Square between 0 to 100 :0 1 4 9 16 25 36 49 64 81 100  Positive number, which is divisible by 10: 10 20 30 40 50 60 70 80 90  Powers of two less than n: 1 2 4 8 16 32 64   Explanation:In the above program, two integer variable "squ and n" is defined, then three while loop is declared, which is used to calculate different values, that can be described as follows: In the first while loop both "n and squ" variable is used, in which n is used for check range and "squ" is used to calculate the square between 1 to 100. The second, while it is used to calculate the positive number, which is divisible by 10, in this only n variable is used, that calculates the value and check its range. Then the last while loop is used which is used to calculate the double of the number, which is between 1 to 100 range.  

Similar Solved Questions

1 answer

People with one copy of the allele that causes sickle cell anemia are called _______, while people with two copies of the allele have the disease.

People with one copy of the allele that causes sickle cell anemia are called _______, while people with two copies of the allele have the disease....
1 answer

What is the relationship between mass and gravitational force between any two objects?

What is the relationship between mass and gravitational force between any two objects?...
1 answer

How do atmic raii vary in group and peroid. why?​

how do atmic raii vary in group and peroid. why?​...
2 answers

London became one of the greatest commercial and shipping

London became one of the greatest commercial and shipping...
1 answer

Tom and sue____two books (buy)

Tom and sue____two books (buy)...
2 answers

What’s the answer?? I’m timed help asappp

What’s the answer?? I’m timed help asappp...
1 answer

A butcher has 10 3/4 pounds of ground beef that will be process at $3.40 per pound. he divides the meat into 8 equal packages. to the nearest cent, what will be the price of each package? explain how you know that your answer is reasonable

a butcher has 10 3/4 pounds of ground beef that will be process at $3.40 per pound. he divides the meat into 8 equal packages. to the nearest cent, what will be the price of each package? explain how you know that your answer is reasonable...
1 answer

In a circle an arc 60 centimeters lon subtends an angle of 5 radians. What is the radius of the circle?

In a circle an arc 60 centimeters lon subtends an angle of 5 radians. What is the radius of the circle?...
1 answer

What is a modernist hero? Select all that apply. an ordinary person optimistic about the future Ouncertain about the future has adventures beyond what most people ever experience has common experiences that everyday people recognize

What is a modernist hero? Select all that apply. an ordinary person optimistic about the future Ouncertain about the future has adventures beyond what most people ever experience has common experiences that everyday people recognize...
1 answer

Natural Hazards: Earthquakes and Volcanoes:Question 3 Which of these tectonic plate boundaries is most likely to form a volcano?

Natural Hazards: Earthquakes and Volcanoes:Question 3 Which of these tectonic plate boundaries is most likely to form a volcano?...
1 answer

At the time the article was written, what had "eluded" Rob Mendez and Prospect High School

At the time the article was written, what had "eluded" Rob Mendez and Prospect High School...
1 answer

Solve 3(y-3) + 2(5+3y) + 24(2y-5) + 6(5-y)

Solve 3(y-3) + 2(5+3y) + 24(2y-5) + 6(5-y)...
1 answer

Find the appropriate percentile from a​ t-distribution for constructing the following confidence interval. 99​% ​t-interval with n = 3.

Find the appropriate percentile from a​ t-distribution for constructing the following confidence interval. 99​% ​t-interval with n = 3....
1 answer

Suppose z varies jointly with x and y. If z = 42 when x = 3 and y = 7, then what is z when x = 7 and y = 8? Do not include "z =" in your answer.

Suppose z varies jointly with x and y. If z = 42 when x = 3 and y = 7, then what is z when x = 7 and y = 8? Do not include "z =" in your answer....
2 answers

Which expressions are equivalent to the one below? Check all that apply. 10x A. 50x/5x B. 10 • 10x - 1 C. 10 • 10x + 1 D. 50x/5 E. (50/5)x F. x5

Which expressions are equivalent to the one below? Check all that apply. 10x A. 50x/5x B. 10 • 10x - 1 C. 10 • 10x + 1 D. 50x/5 E. (50/5)x F. x5...
1 answer

You placed an object into a graduated cylinder. The level of water went from 500 ml to 645ml. The object has a mass of 210 g. What is the density of your object?

You placed an object into a graduated cylinder. The level of water went from 500 ml to 645ml. The object has a mass of 210 g. What is the density of your object?...
2 answers

What time it would be in Los Angeles if it were 7:00 pm in New York City

What time it would be in Los Angeles if it were 7:00 pm in New York City...
1 answer

The numbers 1-4 are each written on an index card. The 4 cards are put into a bag and 2 of them are drawn at random. What is the probability that the sum of the two cards drawn are greater than 5? I actually know the answer to this question (1/3), however, I don’t know how to solve it; please include an explanation.

The numbers 1-4 are each written on an index card. The 4 cards are put into a bag and 2 of them are drawn at random. What is the probability that the sum of the two cards drawn are greater than 5? I actually know the answer to this question (1/3), however, I don’t know how to solve it; please incl...
1 answer

What are the steps to find the lower and upper quartiles of a data set

what are the steps to find the lower and upper quartiles of a data set...

-- 0.047756--