How do you use the for loop to find the sum of a five digit number?
ex) 12345 should have the sum of 15
23456 = 20
but the way I program it, the answer is always = 15. Help me fixed this problem.
this is what I got so far
cout <<"Enter a five digit number: " << endl;
cin >> number;
int sum = 0;
for ( int i = sum;i <= 5; i++)
sum += i;
cout <<"Sum is " << sum << endl;
return( 0 );