# C beginner monthly capital and interest calculating

in this program should do the following:

1: asks for the starting capital

2: yearly interest

3: how many months

Then it will print out every month with the correct amount.

eg.

Output: How much?

input: 1000

Output: yearly interest?

input: 120

Output: How long?

Input: 3

1. month: 1100 USD
2. month: 1200 USD
3. month: 1300 USD

I tried with two options but none of them worked.

Here i tried with two for loops, but all of the outputs are the starting capital:

``````#include <stdio.h>
#include <stdlib.h>

int main()
{
int capital, month,  monthsum;
double interest, monthinterest;

printf("How much is the starting capital\n");
scanf("%d", &capital);

printf("How much is the interest in a year?\n");
scanf("%lf", &interest);

printf("How long?\n");
scanf("%d", &month);

monthinterest= interest / 12;

for (int i = 1; i <= month; i++) {
{

for (int a = 1; a <= month; a++)
monthsum = capital * monthinterest;

}
printf("\n%d. month: %d USD", i, monthsum);

}
return 0;
}
``````

And this one gives a wrong answers

``````#include <stdio.h>
#include <stdlib.h>

int main()
{
int  month,  monthsum;
double capital, interest, monthinterest, monthinterest2;

printf("How much is the starting capital\n");
scanf("%lf", &capital);

printf("How much is the interest in a year?\n");
scanf("%lf", &interest);

printf("How long?\n");
scanf("%d", &month);

monthinterest=  interest / 12;
monthinterest2 =  capital / monthinterest;

for (int i = 1; i <= month; i++) {

printf("\n%d. month: %f USD", i, capital + i * monthinterest2);
}

return 0;
}
``````