Thanks for the help. I fixed the char problem and are working on the calculation now.
Principal and number of times are both showing as 0. Interest rate is showing at 929269760 and number of years is showing at a similar ridiculous rate. Why?
Code:
/* Financial Math - Compound Interest */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
printf("Financial Math - Compound Interest v2.0 \n");
float principal = 0, interestRate = 0, numberUnits = 0, timeUnits = 0, amount01, amount02, power, test;
char principalInput[100], interestInput[100], numberInput[100], timeInput[100];
printf("Compound interest is calculated with the use of the compound interest formula; A = P[(1+r/100n)^nt]");
printf("\nPrincipal (initial amount): ");
fgets(principalInput, 10, stdin);
sscanf(principalInput, "%d", &principal);
printf("Interest rate (%): ");
fgets(interestInput, 10, stdin);
sscanf(interestInput, "%d", &interestRate);
printf("Number of times compounded per time unit: ");
fgets(numberInput, 10, stdin);
sscanf(numberInput, "%d", &numberUnits);
printf("Number of years: ");
fgets(timeInput, 10, stdin);
sscanf(timeInput, "%d", &timeUnits);
printf(" Principal: %d, Interest rate: %d", principal, interestRate);
printf("\n Number of times: %d, Number of years: %d \n", numberUnits, timeUnits);
amount01 = principal * (1 + (interestRate/(100 * numberUnits)));
power = (numberUnits * timeUnits);
amount02 = pow(amount01, power);
printf("Compound interest = $%i", amount02);
return 0;
}