PROGRAM 13
// FILENAME: PROG13.CPP // THIS PROGRAM CALCULATES AND PRINTS THE SQUARE AND CUBE OF A GROUP OF // THAT IS DETERMINED BY THE USER. #include #include #include #include #include void main () { clrscr (); char pause; int number, increment, start, end, quantity, count; #include gotoxy (6, 7); cout << " PROG13.CPP "; gotoxy (48, 14); pause = getch (); window (1, 1, 80, 25); textbackground (3); clrscr (); cout << "ENTER STARTING NUMBER. "; cin >> start; cout << "\nENTER INCREMENT. "; cin >> increment; cout << "\nENTER HOW MANY. "; cin >> quantity; end = start + quantity * increment; count = 0; clrscr (); cout.setf (ios :: showpoint); cout << "\nSTARTING NUMBER: " << setw (5) << start; cout << "\nINCREMENT: " << setw (5) << increment; cout << "\nHOW MANY: " << setw (5) << quantity; cout << "\n\n NUMBER SQUARE CUBE\n"; for (start; start < end; start += increment) { cout << "\n" << setw (14) << start; cout << setw (14) << long (pow (start, 2)); cout << setw (14) << long (pow (start, 3)); count = count + 1; if ((count % 15 == 0) && (count != quantity)) { cout << "\n\nPRESS ENTER KEY TO CONTINUE. "; pause = getch (); clrscr (); cout << " NUMBER SQUARE CUBE\n"; } } return; } // FILENAME: COPY.H // SEE PROGRAM 7. // OUTFILE: PROG13.OUT ENTER STARTING NUMBER. 1 ENTER INCREMENT. 2 ENTER HOW MANY. 10 STARTING NUMBER: 1 INCREMENT: 2 HOW MANY: 10 NUMBER SQUARE CUBE 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 11 121 1331 13 169 2197 15 225 3375 17 289 4913 19 361 6859
BACK TO CIS162 PAGE.