How to count backwards (Print the numbers N, N - 1, ..., 0 (included)) in C++

1 Answer

0 votes
#include <iostream>

int main() {
    int n = 5;
    
    for (int i = n; i >= 0; i--) {
	    std::cout << i << " ";
    }
}



/*
run:

5 4 3 2 1 0 

*/

 



answered Jul 20, 2025 by avibootz
...