Question

In: Computer Science

What should be put in the blank position below in order to make the loop execute...

What should be put in the blank position below in order to make the loop execute exactly 5 times? (C program)

int i ;

for ( i = 10 ; ______ ; i-- ){
  printf ( "%d\n", i ) ;
}

Solutions

Expert Solution

Based on the condition in the question loop needs to execute 5 times.

So, We need to fill the blank position with i>5

Step1:

Initially the value of i is 10 then we check the condition i>5 if it is true then enter into the loop and print the i value.

Step2:

Next it decrement the i value i.e..(i--) and check the condition again I>5 if it is true then enter into the loop and print the i value.

Step3:

The loop will run till the condition is true i.e..(i>5). Once the i value less than or equal to 5 loop will be exit.

Code:
#include <stdio.h>

int main()
{
int i ;

for ( i = 10 ; i>5; i-- )
{
printf ( "%d\n", i ) ;
}
}

O/p:

10

9

8

7

6

As per the condition loop ran only 5 times.

Screenshots:


Related Solutions

Put yourself in the position of a management trainer. You have been ask to make a...
Put yourself in the position of a management trainer. You have been ask to make a short presentation to a group of small and medium size organization association at the monthly luncheon. The topic you are to speak on is "How each of you can use management by objectives for better planning and control." What will you tell them and why?
What does Tesla need in order to execute their plan selling their cars direct to the...
What does Tesla need in order to execute their plan selling their cars direct to the customer. What resources do they need? How would they do it? Explain in your own words.
What actions should a financial manager make in order to maximize the value of the company's stock?
What actions should a financial manager make in order to maximize the value of the company's stock? does it mean that maximizing profit results to maximizing the company's stock value?
If you copy the functions below into your Python environment and execute q2([1,2,3]), you should see...
If you copy the functions below into your Python environment and execute q2([1,2,3]), you should see this printed output: None [1, 2, 3, 6] [1, 2, 3, 6, 12] [1, 2, 3, 6] [1, 2, 3] In terms of the initial value of the aList variable in q2, [1,2,3], explain each line of output. E.g. why is the first line None? Why is the second line [1,2,3,6]? Etc. def q2a(inputL): s = 0 for i in range(len(inputL)): s = s...
To make a phrase/words, solve the 18 application of derivatives below.  Then replace each numbered blank with...
To make a phrase/words, solve the 18 application of derivatives below.  Then replace each numbered blank with the letter corresponding to the answer for that problem. Show all solutions on the answers given below. "   __ __ __ __ __ __ __       __ __ __ __      __ __ __ __ __ __ __      __ __ __ __ __      __ __ __ __ __"        "__ __ __ __ __ __ __      __ __      __      __ __ __ __ __ __ __      __ __ __ __ __      __ __ __ ."      Derivative Application...
1. Read the case study below, and put yourself in Maria's position to answer these questions:...
1. Read the case study below, and put yourself in Maria's position to answer these questions: What is the ethical issue that Maria faces? Who benefits/loses if she decides to do as Hans says? What would you do if you were in her shoes? What does this decision reveal about you? Cosmetic Applications Topic: Package Labeling and Advertising Characters: Hans, Cosmetics Group Product Marketing Manager Maria, Assistant Marketing Communications Manager Maria is an Assistant Marketing Communications Manager with TruBlush Cosmetics,...
Any amounts that should be blank must have a zero (0)!For each employee listed below,...
Any amounts that should be blank must have a zero (0)!For each employee listed below, determine the employer’s tax liability for the payroll period, as well as the totals for each employee and for each tax. Use the following tax rates.Social Security, 6.2%, with a maximum taxable earnings of $118,500.Medicare, 1.45%, with no cut-off.State Unemployment, 5.4%, with a maximum taxable earnings of 7,000.Federal Unemployment, .6%, with a maximum taxable earnings of 7,000.Name           BeginningCumul-ativeCurrentPay           EndingCumul-ativeAmount of TaxTotal Taxes on EmployerSoc. Sec.TaxesMedi-careTaxesSUTATaxesFUTATaxesAlice116,9002,300Bob48,0002,000Cindy6,8001,080Dale127,8001,580
When should a person execute a durable power of attorney? What preferences does an advance directive...
When should a person execute a durable power of attorney? What preferences does an advance directive establish? When is CPR indicated, and when is it not? How would you explain the statement that “CPR should not be the standard of care for the chronically ill resident of a long-term care facility”? Explain the difference between starvation and the malnutrition/dehydration of the dying process.
In order to be effective, which type of executives should make up the majority of the...
In order to be effective, which type of executives should make up the majority of the audit committee members? Discuss in 30–50 words.
make a plot of the data in the table below , plot position versus time time...
make a plot of the data in the table below , plot position versus time time squared (t2 ). make sure to label your graph properly.( Y axis title with units, X axis title with unit, title of the graph with equation , major tick marks. use data to plot the graph manually. use proper scal measurement position(m) time(s) time2 (s2 ) 1 0 0 0 2 5 1 1 3 21 2 4 4 46 3 9 5 82...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT