-4

For this Python for loop:

for i in range(n-2,-1,-1):

What is the equivalent code syntax in C++?

ouflak
  • 2,408
  • 10
  • 40
  • 47
Mezo
  • 113
  • 15
  • 1
    Also try reading [ask] and https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions. – Karl Knechtel Nov 24 '20 at 12:34
  • 3
    This question is currently involved in a [controversial meta discussion](https://meta.stackoverflow.com/questions/403116/) – TheMaster Nov 25 '20 at 18:31
  • I think you can self-delete a post even if it has been forcefully un-deleted. I'm not sure why this un-deletion was done to your post. The flurry of downvotes is not going to make it easier on your account. Please read [What can I do when getting “We are no longer accepting questions/answers from this account”?](https://meta.stackoverflow.com/questions/255583/what-can-i-do-when-getting-we-are-no-longer-accepting-questions-answers-from-th) so you're well informed prior to a possible Question ban. – Scratte Nov 26 '20 at 20:27
  • Does this answer your question? [How can I convert this python for-loop using a range into C++?](https://stackoverflow.com/questions/64988089/how-can-i-convert-this-python-for-loop-using-a-range-into-c) – Johannes Kuhn Nov 27 '20 at 04:26
  • @Scratte Given there are two answers now deleting would not be possible now. – TheMaster Nov 27 '20 at 05:58
  • 2
    @TheMaster Apparently now users think that the author has posted a debugging problem, since they seem to think it needs the debugging details. – Scratte Nov 27 '20 at 11:15

1 Answers1

5

The equivalent in C++ would be

for(i = n-2 ; i > -1 ; --i)
  { /* whatever */ }