-
Notifications
You must be signed in to change notification settings - Fork 0
/
p6.10.c
34 lines (30 loc) · 759 Bytes
/
p6.10.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "details.h"
#include <stdio.h>
long sum_squares(int x, int y);
int main(void)
{
printf("This program calculates the sum of "
"all integer squares in a range.\n");
printf("Please enter the lower and the upper integer of the range:\n"
"(q to quit):\n");
int m, n;
while(scanf("%d %d", &m, &n) == 2)
{
printf("The sum of squares for all integers within the "
"limit %d and %d is %ld\n", m, n, sum_squares(m, n));
printf("Please enter the lower and the upper integer of the range:\n"
"(q to quit):\n");
}
printf("Done!");
details();
return 0;
}
long sum_squares(x, y)
{
long z;
for(x; x <= y; x++)
{
z += (x*x);
}
return z;
}