• Register
0 votes
41 views

Problem:
When I compile and run the code below with either count++ or ++count substituted for the variable X, the output is identical; in both cases.

for (int count = 1; count < 11; x)
{
    std::cout << count << endl;
}

Can you please explain the order in which the three actions are evaluated in the for loop header, and explain exactly where the iterations occur when using count++ and ++count?

6 2
830 points

1 Answer

1 vote

Solution:

All we need to know is: Increment operators are used to increasing the value by one while decrement works opposite increment.

Pre-increment (++i) − Before assigning the value to the variable, the value is incremented by one.

Post-increment (i++) − After assigning the value to the variable, the value is incremented.

we declare loop in our codes like below:

 

for (initialization; condition; increment/decrement)
    code;

But iteration follows the steps as given below:

{
    initialization;
    while (condition)
    {
        code;
        increment/decrement;
    }
}

 

5 1
1,480 points

Related questions

0 votes
1 answer 8 views
8 views
I want to develop an increment statement and decremnet statement . Is there anyone here that can give me a hint on how to start ?
asked Sep 25 okeke 360 points
0 votes
1 answer 41 views
41 views
Problem: I am working with loops. My query is that can I increment a foor loop by 2? If yes, then how? Please explain in detail and with syntax and examples because I am a newbie and have no experience in programming. Thanks
asked Oct 15 Sheeza 3.6k points
0 votes
2 answers 546 views
546 views
Problem: A ________ value in a loop can be either a positive or a negative number. Is this true of False? I am bit confused can anyone suggest?
asked Sep 29, 2019 anonymous
0 votes
1 answer 1.7K views
1.7K views
I installed pyhton in my stystem. But my system can not find pyton executable after installing python it shows me some error like : error: can't find python executable also my node-gyp is failing: $ $(npm config get python) Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC ... node -v v7.9.0 gyp ERR! node-gyp -v v3.6.0 gyp ERR! not ok can anyone help me out to get rid of this error.
asked Mar 10 LizzyM 6.1k points
0 votes
1 answer 51 views
51 views
Problem: I am new, I need help, can anyone help? Using wildcard metacharacters, how can one indicate a number is either 1, 2, 3, or 4? a. 1-4 c. [1234] b. [1-4] d. [1,2,3,4]
asked Feb 21 maddi86 5.4k points