QUOTE(grimmben @ 4 Dec, 2007 - 07:20 AM)

CODE
//Ch7AppE08.cpp – displays the numbers 0 through 117, in increments of 9
//Created/revised by <your name> on <current date>
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int product = 9;
for (int count = 117; count >= 9; count = count - 9) {
product*=count;
}
cout << count << endl;
//display number's increments of 9
return 0;
} //end of main function
First please post your question because it helps us determine your issue quicker.
I think I found your issue.
Your for loop is not correctly created. Also based on what you are trying to do why start at 117 why not 0?
First the parameters for the for loop are not correct. 1. You do not need count = count -9 because count - 9 is setting count equal to that already. Also your equation inside the loop is incorrect. It should be count = count * product;
But I believe the way you created your code is not what you actually want. For loops can increment variables for you so if you start from 0 the for loop would look like for(int count=0;count<=117;count+9). That says count is = 1 for the first loop and when it comes back it adds 9 to that and sets it equal to count. It will do this until the count value is less then or equal to 117.
Also you need to have your cout << statement inside the loop so every time the for loop runs it will display the current count number. If it is outside it will display the last number the loop set count to in this case 117.
You do not need the product variable because the for loop takes care of calculating numbers and making sure they are in incriments of 9.
Also their is no need for using std::cout and endl. Just uses this using namespace std;
Here would be the corrrections
CODE
#include <iostream>
using namespace std; // Better to uses
int main()
{
for (int count = 0; count <=117; count+9) // I would suggest starting with 1 and then working up
{
cout << count << endl; // Displays count each time the loop runs and sets count to a new value.
}
return 0;
} //end of main function
This post has been edited by lockdown: 4 Dec, 2007 - 06:40 AM