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 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?
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...
What type of order initiates a short position? BTO STO BTC STC What type of order...
What type of order initiates a short position? BTO STO BTC STC What type of order closes out an existing short position? BTO STO BTC STC   What is the type of order where a pair of orders is entered and one is canceled when the other is filled? OCO IOC AON FOK An order that is automatically canceled at the close of the trading day is a ______ order. GTC stop loss stop limit day An order that is automatically...
What happens to the Delta and Vega of the at-the-money long put position if implied volatility...
What happens to the Delta and Vega of the at-the-money long put position if implied volatility increases? What happens to the Gamma of the at-the-money long put position if the implied volatility increases? Please use analytical formulas to prove.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT