View Single Post
Old Mar 18th, 2005, 3:21 AM   #7
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
lol you could do that in a nice for loop would be better then a while as you are using while in the wrong instance i think anyways.

#include <iostream>
#include <stdlib.h>
 
using namespace std;
 
int main (void)
{
// f(x)=x^2-8x+15
 
for (int x = 0; x < 11;x++)
{
int val = ((x*x)-(8*x))+15;
cout << "F(" << x << ") = (" << x << " ^ 2) - (8 * " << x << ") + 15 = " << val << endl;
} 
system("PAUSE");
return 0;
}


i was always taught that you use while loops when you dont no a definate result to end the loop

eg. while (start != end){
do something
}
Berto is offline   Reply With Quote