Hello I have been encountering some problems with my void function coding. When I enter my three values the command prompt just stops and nothing happens, I would appreciate any advice thanks.
Code:
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void repayments(float, float, float); // function prototype
int main()
{
float cost, deposit, interest_rate;
// get values from user
do
{
printf("Enter the cost of the car:\n");
scanf("%f", &cost);
if (cost <= 0)
printf("ERROR: the cost must be higher than 0\n");
}
while(cost <= 0);
do
{
printf("Enter the deposit paid:\n");
scanf("%f", &deposit);
if (deposit <= 0 || deposit > cost)
printf("ERROR: the deposit can't be less than or equal to 0 or greater than cost\n");
}
while(deposit <= 0 || deposit > cost);
do
{
printf("Enter the interest rate:\n");
scanf("%f", &interest_rate);
if (interest_rate < 0 || interest_rate > 100)
printf("ERROR: Interest rate must be between 1 and 100\n");
}
while(interest_rate < 0 || interest_rate > 100);
repayments(cost, deposit, interest_rate); // function call with 3 arguments
return 0;
}
void repayments(float c, float d, float ir) // function header
{
short int i; // local variable
for(i = 1; i <= 5; i+12); // 5 iterations - 12, 24, 36, 48, 60
{
printf("Your repayment after %hd months is %f\n" , i+12, ((c - d)/i+12)*(ir));
}
return;
}