Untitled
unknown
plain_text
3 years ago
461 B
10
Indexable
#include <stdio.h>
double f4(int n) {
double x;
if (n == 0) {
return 0;
}
scanf("%lf", &x);
if (n % 2 == 0) {
return x + f4(n-1);
} else {
return f4(n-1);
}
}
int main() {
int n;
printf("Enter the number of values:\n");
scanf("%d", &n);
printf("Enter %d real numbers:\n", n);
double sum = f4(n);
printf("Sum of even positions: %.1lf\n", sum);
return 0;
}
Editor is loading...