use of loops

How do I create a program with even numbers ranging from 2 to 100.
The only example i have in my book is of integers
0 to 100
#include<iostream>
using namespace std;

int main()
{ const number Max = 80
numtotal =2
for(number i=2;<=Max;++ number)
{total += i;

}
cout<<total<<endl;
return 0;
++number this increments number by one. In you case you want to increment by _?
you wanna add numbers from 2 to 100 ?
2+4+6+8+...+100.

if so, here's the loop

1
2
3
4
5
6
7
8
9
10
11
12
#include<iostream>
using namespace std;

int main()
{
	int total=0,i;
	for(i=2;i<=100;i=i+2)
	total=total+i;
	cout<<total;
	cout<<endl;
	return 0;
}
Topic archived. No new replies allowed.