Chapter+4_Ex+4.17

4.17
 * exercise number:**
 * description of objective:**

code format="cpp" using namespace std;
 * code:**
 * include
 * 1) include
 * 2) define w5 cout.width(5)//set width so that the list looks arranged
 * 3) define w7 cout.width(7)
 * 4) define w13 cout.width(13)

int square(int x);//declare a function to square number, so that program looks organized int cube(int y);//declare a function to cube number int main(int argc, char *argv[])//main function {   int starting, ending;//two integers to set the limit of the calculation cout<<"Enter starting value: ";//ask for user input cin>>starting;//store user input as starting variable cout<>ending;//store into ending variable cout<<endl;//switch line

cout.setf(ios_base::fixed);//set the output base to be fixed cout.setf(ios_base::left);//allign words to the left of the fixed space w5;//pre set width cout<<"X"; w13; cout<<"X_SQUARED"; w13; cout<<"X_CUBED"; cout<<endl;

int n;//a variable that counts how many lines remaining while(starting<=ending){//start of loop; each loop squares and cubes the x value w5; cout<<starting;//print out the current number to be calculated w13; cout<<square(starting);//square the number w13; cout<<cube(starting);//cube the number starting +=1;//the number +1 everytime the loop finishes cout<<endl;//switch line }

cin.ignore(100,'\n');//ignore 100 character and enter cin.get;//to stop the program from quitting without showing important information

system("PAUSE"); return EXIT_SUCCESS; }

int square(int x){//content of function x = x*x;//square the value return x;//return the result }

int cube(int y){ y= y*y*y;//cube the value return y;//return value }**

code