My for loop was okay but my while loop is not. I don't know how can I do it. It should be 10 to 1 not 1 to 10

#include <iostream>
using namespace std;

int main ()
{

int num = 0;

cout << "Using for loop\n";

for(num = 10; num >= 1; num--)
{
cout << num << "\n";
};

cout << "Using while loop\n";
while(1)
{
cout << ++num << "\n";
if(num >=10)
break;

} while(num < 10);

return 0;

}
try this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Example program
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int num = 10;

    while(num > 0)
    {
        cout << num-- << "\n";
    }
  
  return 0;
}
Thanks man. :')
Topic archived. No new replies allowed.