Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
461 B
3
Indexable
Never
#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;
}