Greeting to all,
I have been trying to apply "fprintf()","fopen()" and "fclose()" into the following source code but still fail to get the right way. As I do not have any C program book to refer to, I really appreciate it if someone could show me how should I go about it. As I have mentioned in my previous thread, I am trying to transfer the output (refer to the source code below) to a text file such as showing the output in the notepad file.
#include <stdio.h>
#include <math.h>
main()
{
double p,min,max,temp;
double pymt[3][100],total[3][100];
int a=0;
int n;
printf ("Enter loan amt(p): ");
scanf ("%lf",&p);
printf ("\nKey in minimun interest rate(i): ");
scanf ("%lf",&min);
printf ("\nKey in maximun interest rate(i): ");
scanf ("%lf",&max);
printf("%s\t%s\t%s\t%s\n","Monthly payment","Total payment","Interest rate in %","Year");
for(n=20;n<=30;n+=5){
int b=0;
temp=min;
for(;temp<=max;temp+=0.25){
pymt[a]=((temp/100)*p)/(1-(pow((1+(temp/100)),-n)));
total[a] = pymt[a]*12*n;
printf("%.2f\t\t%.2f\t\t%.2f\t\t\t%d\n",pymt[a],total[a],temp,n);
b++;
}
a++;
}
return 0;
}