How do I write a C++ for loop that displays the following set of numbers:

0, 10, 20, 30, 40, 50 ..... 1000

I don't know anything about loops, so any help will be much appreciated

Thank you much. :)

Recommended Answers

All 5 Replies

Here's a tutorial on 'for loops'

ok when I do it to 1000, it only starts counting from 702

int main()
{
  // declare a variable
  int i;
  for(i= 0; i < 1001; i++)
    cout << i << endl;



     system("PAUSE"); 
     return 0;
}
#include <iostream>
using namespace std;

int main() {
	for(int i = 0; i <= 1000; i+=10){
		cout << ' ' << i;
	}
	return 0;
}

It's works but why does it show so many zeros in additon to the other numbers

nvm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.