I'm just trying to make a simple loop that adds all the integers between 1 and a maximum number. When I run the program I get a really large number, what's wrong?
#include <iostream>
usingnamespace std;
int main()
{
//variables
int num=1;
int max;
int sum=0;
cout<<"Enter a positive number: ";
cin>>max;
while(num<=max)
{
sum = sum+num;
num++;
cout<<sum;
}
system("pause");
}