Hi, I have been trying to figure out how to add the output of a for loop together.
In the part of the program I am working on I am suppose to create a program that adds the odd numbers together and gives me a total output (ex 1,3,5,9,11 = 36) . I am later suppose to do other stuff with those numbers but am pretty confident on that portion of the program.
so far i Have, I have tried things such as adding in a second for loop to add the output together but when i so it seems to change the output of the first for loop, All i need is the total if H, that is all, not it it showing each loop Any ideas... Thanks
using namespace std;
int input = 0,
i = 0,
h = 0,
k = 0;
cout << "enter a number ";
cin >> input;
for ( i = 1; i <= input * 2; i += 2)
cout << " i is " << i;
for (d = 0 ; i <= input * 2; i+=2)
cout << "h is " << h