• Register
0 votes
57 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

Please log in or register to answer this question.

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 2
1,480 points

Related questions

0 votes
1 answer 24 views
24 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, 2020 okeke 360 points
0 votes
2 answers 655 views
655 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 238 views
238 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, 2020 Code Learner 5.7k points
0 votes
1 answer 23 views
23 views
Problem: I'm trying to run the following command: npm install -g bower gulp cordova ionic tsd@next karma-cli protractor node-gyp coffee-script js-beautify typescript npm-check I have installed Python, Visual Studio Express and node-gyp so thought I'd be good to go, however I get the errors:
asked Jan 8 Mashhoodch 9.1k points
0 votes
1 answer 2.5K views
2.5K 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, 2020 LizzyM 6.1k points
0 votes
1 answer 37 views
37 views
Explain with an example?
asked Oct 8, 2020 jagruthi 680 points
0 votes
1 answer 82 views
82 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, 2020 maddi86 5.4k points
0 votes
1 answer 16 views
16 views
Problem: Hello kodlogs, I have a doubt in python, I am new in python programming language and want to know that about the &ldquo;if&rdquo; concept that can we use it inside the while loop or in other loop is there any restriction in using it ?. Though its a easy question but wondering how can we achieved it and what are the various possibilities to do it in the python language.
asked Jun 15, 2020 Gavin 15.3k points
0 votes
1 answer 17 views
17 views
Problem: Hi there! I am confused in while loops and I need to write a program in which a value is taken as input from the user. If the value is less than 0, the program should increment it by 5 as long as the value remains less than 0. As the value becomes greater than or equal to 0, it should print the number of times the value has been incremented and the final value. Any help??
asked Jan 21 Code Learner 5.7k points