i want my code to show a set of ten integers, each seperated by an inputted interval, (e.g. input 3, the set is {1, 4, 7, 10, 13, 16, 19, 21, 24, 27} ). When i input 1, the number of intergers in my set is correct. However, the number I input also limits the number of integers in my set. For 3, I only see 4 integers. For 15, I only see 1. Whats the deal???
Here's my code:
CODE
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
string response;
cout << "Would you like to run a case? (y/n) \n";
cin >> response;
while (response == "y") {
cout << "Please enter the desired step size. ";
int size;
cin >> size;
int i;
for (i=1; i <=10; i= i + size)
{
cout << i << " ";
}
}
return 0;
}
This post has been edited by miensta: 2 Jun, 2008 - 05:23 PM