int main(void) { const long MIN = -10000000L; const long MAX = 10000000L; long start, stop; double answer; printf("This program computes the sum of the squares of" "integers in a range.\nThe lower bound should not " "be less than %ld and\n the upper bound " "should not be more then %ld.\nEnter the limits " "(0 for both limits to quit):\nlower limit: ", MIN, MAX); start = get_long(); printf("upper limit: "); stop = get_long(); while (start != 0 || stop != 0) { if (bad_limits(start, stop, MIN, MAX)) { printf("Please try again.\n"); } else { answer = sum_squares(start, stop); printf("The sum of the squares of the integers "); printf("from %ld to %ld is %g\n", start, stop, answer); } printf("Enter the limits (0 for both limits to quit):\n"); printf("lower limit: "); start = get_long(); printf("upper limit: "); stop = get_long(); } printf("Done.\n"); return 0; }
int main() { const int MIN = -1000; const int MAX = 1000; int start; int stop; double answer; printf("This program computes the sum of squares of " "integers in a range.\nThe lower bound should not " "be less than -1000 and\nthe upper bound should not " "be more than +1000.\nEnter the limits (enter 0 for " "both limts to quit):\nlower limit: "); start = get_int(); printf("upper limit: "); stop = get_int(); while (start != 0 || stop != 0) { if (bad_limits(start, stop, MIN, MAX)) printf("Please try again.\n"); else { answer = sum_squares(start, stop); printf("The sum of the squares of the integers from "); printf("from %d to %d is %g\n", start, stop, answer); } printf("Enter the limits (enter 0 for both limits to quit): \n"); printf("lower limit: "); start = get_int(); printf("upper limit: "); stop = get_int(); } printf("Done.\n"); return 0; }