for looping help

the book im learning from told me to write this code but when i do i get
error: 'endl' was not declared in this scope. on line 9
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
int main()
{
    int x = 0;
    int i;
    for (i = 1; i <= 100; i++) {
    x += i;
    }
    cout << x << endl;
    return 0;
}
Last edited on
type this between main function and #include <iostream>:

1
2
using std::cout;
using std::endl;
Type using namespace std; in between main function and #include <iostream>. It automatically includes cout, cin, endl, etc.
thanks
Topic archived. No new replies allowed.