Convert Counter-Controlled While Loop To For Loop

hello everyone, I have written a program that will print numbers 1 through 10 as well as show what they are when multiplied by 2 and by 10. I have written it using a counter controlled while loop and wish to use a for loop instead, but I'm not sure how to use it. could someone help? I know it's not really a question but I'm a novice to cpp and my professor didn't really teach us how to use for loops. thanks!

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

using namespace std;

int main ()
{
	int x = -1;
	while (x++<10)
	{
		cout << setw(6) << x 
		     << setw(6) <<(x*2) 
		     << setw(6) <<(x*10)
		     << endl;
	}
	return EXIT_SUCCESS;
}
1
2
3
4
5
6
7
8
9
10
11
12
int main ()
{

	for(int x=-1;x<10;x++)
	{
		cout << setw(6) << x 
		     << setw(6) <<(x*2) 
		     << setw(6) <<(x*10)
		     << endl;
	}
	return EXIT_SUCCESS;
}
Topic archived. No new replies allowed.