Hi!

First of all, I know that my code in regard to solving the task (logic) is still wrong and I will deal with it afterwards.

For now, I am stuck at the technical details, since my program is even not starting and apparently not entering the main function and I do wonder why not?

Has it something to do with the fact that the return type of my function shall be a double value, whereas the return type of the main function shall be an integer value?

Code:

#include <stdio.h>
double ln2iter(int number_subtotals) {
int i, j;
double base = -1, numerator = 1, sum = 0;
for (i = 1; i < (number_subtotals + 1); i++) {
numerator *= base;
} for (j = 1; j <= number_subtotals; j++) {
sum = sum + ((numerator) / j);
}
return sum;
}
int main() {
int n;
double result;
printf("How many subtotals do you want to have calculated?\n");
scanf("%d", &n);
result = ln2iter(n);
printf("The natural logarithm of 2 with %d subtotals is %lf.\n", n, result);
return 0;
}