[Solved] Do and While Loop

You can use the while loop as follows: int i=1; while(i<=7) { sal = load(); rate = calcRate(sal); calcRaise(sal, rate, &raise, &totraise); calcNewSal(sal, raise, &newsal, &totnewsal); calcTotSal(&sal, &totsal); print(sal, rate, raise, newsal, totsal, totraise, totnewsal); fflush(stdin); i++; } And the do-while as follows: int i=1; do { sal = load(); rate = calcRate(sal); calcRaise(sal, rate, … Read more

[Solved] for loop containing all equals statements C

You copied the statement wrong. In the program you cited in your comment there’s only one for statement which approximates what you posted above: for(time=0,count=0;remain!=0;) In this case the “initialization” portion of the for statement is time=0,count=0 Note that the character between the initialization of time and count is a comma, not a semicolon. This … Read more

[Solved] How are variables involved in a for loop’s body if they are not defined? [closed]

In your for loop, the variable result Is created outside of the for loops scope. Essentially, you are just changing the result variable that has already been created. If you attempted to create a new variable within the for loop such as “newResult = base * result”, it would fail if you attempted to use … Read more

[Solved] Java questions using only for-loops [closed]

For a consider this : /*Outputs a serious of 5 numbers, starting at 1. The difference between one number to the next one is a sequence of numbers, starting at 1 and incremented by 1 i.e: 1,2,3,4,5 */ //represents the difference between one number and the next one. //the first difference is 1. int step … Read more

[Solved] Swift 4 need help to make triangle using (*)

Not quite equilateral but as close as you’re likely to get with character graphics. The main things are that you need an odd number of asterisks on each line for centering to work and you need to calculate an offset. (And, even so, you need output in a monospaced font for this to look right.) … Read more

[Solved] increment in for loop of c++

Answering the literal question as stated… The reason for the warning is simply because the left side of the comma in the for loop, third section, will have no effect. i+8 does not change anything, but rather returns a value. Instead, you are wanting the compound assignment addition operator, += i+=8, which will add 8 … Read more

[Solved] For loop with variable step size – C++

You could try using ternary operators. It makes the readability of your code more difficult (my opinion, but some people like it), but you put everything inside your for statement. For the numbers that can be divided by 3, for instance: for (int i = 1; i < N; i = (((i+1)%3 == 0) ? … Read more