Function Main
Declare Integer n, m, i, j
Declare Real s, u
Output "Enter a number of terms to calculate:"
Input m
Output "Enter First term index:"
Input n
Assign m = INT(( m + 9) / 10)
Assign s = 0
For i = 1 to 10
For j = 1 to m
Assign u = 1 / n / n
Assign s = s + u
Assign n = n + 1
End
Output s
End
End
#include <stdio.h>
int main() {
int n, m, i, j;
double s, u;
printf("Enter a number of terms to calculate:");
scanf("%d", &m);
printf("Enter First term index:");
scanf("%d", &n);
m = (int) ((double) (m + 9) / 10);
s = 0;
for (i = 1; i <= 10; i++) {
for (j = 1; j <= m; j++) {
u = (double) 1 / n / n;
s = s + u;
n = n + 1;
}
printf("%f\n", s);
}
return 0;
}
Enter a number of terms to calculate:5
Enter First term index:5
0.040000
0.067778
0.088186
0.103811
0.116157
0.126157
0.134421
0.141366
0.147283
0.152385
Function Main
Declare Integer n, count
Declare Real x, term, sum, accuracy
Output "Enter value of x: "
Input x
Assign accuracy = 0.0001
Assign n = 1
Assign term = 1
Assign sum = 1
Assign count = 1
While n <= 100
Assign term = term * x / n
Assign sum = sum + term
Assign count = count + 1
If term < accuracy
Assign n = 999
Else
Assign n = n + 1
End
End
Output "Terms: " & count & " and sum is " & sum
End
#include <stdio.h>
int main() {
int n, count;
double x, term, sum, accuracy;
printf("Enter value of x:");
scanf("%lf", &x);
accuracy = 0.0001;
n = 1;
term = 1;
sum = 1;
count = 1;
while (n <= 100) {
term = term * x / n;
sum = sum + term;
count = count + 1;
if (term < accuracy) {
n = 999;
} else {
n = n + 1;
}
}
printf("Terms:%d and sum is %lf\n", count, sum);
return 0;
}