C
c_beginner
yes, this is my how work question. Since I am lack in getting
an assistance with my lab work I put this in this advance group.
Sorry for the trouble I am making.
Write a program to calculate the compound interest.
#include<stdio.h>
#include<stdlib.h>
double intrest(double tot_amount,float percent)
{
double temp;
if(percent < 0.0 || percent > 100.0)
{
printf("un-reasonable intrest rate, enter again\n");
fscanf(stdin,"%f",percent);
}
temp = (tot_amount * percent) / 100;
return temp;
}
int main(void)
{
double intrest_rate,cpnd_intrest,prnc_amount,percent;
unsigned short year,i;
printf("enter the percent of intrest,amount,year\n");
fscanf(stdin,"%f%f%d",&percent,&prnc_amount,&year);
if(year > 50)
{
printf("kindly input the reasonable year of return\n");
fscanf(stdin,"%d",&year);
}
else
{
intrest_rate = intrest(prnc_amount,percent);
cpnd_intrest = prnc_amount*(1+intrest_rate);
for(i = year ; i< year ; i++)
cpnd_intrest = cpnd_intrest * i;
}
printf("the compound intrest is %f\n",cpnd_intrest);
return 0;
}
I am getting a strange output when I run the program.Kindly help.
an assistance with my lab work I put this in this advance group.
Sorry for the trouble I am making.
Write a program to calculate the compound interest.
#include<stdio.h>
#include<stdlib.h>
double intrest(double tot_amount,float percent)
{
double temp;
if(percent < 0.0 || percent > 100.0)
{
printf("un-reasonable intrest rate, enter again\n");
fscanf(stdin,"%f",percent);
}
temp = (tot_amount * percent) / 100;
return temp;
}
int main(void)
{
double intrest_rate,cpnd_intrest,prnc_amount,percent;
unsigned short year,i;
printf("enter the percent of intrest,amount,year\n");
fscanf(stdin,"%f%f%d",&percent,&prnc_amount,&year);
if(year > 50)
{
printf("kindly input the reasonable year of return\n");
fscanf(stdin,"%d",&year);
}
else
{
intrest_rate = intrest(prnc_amount,percent);
cpnd_intrest = prnc_amount*(1+intrest_rate);
for(i = year ; i< year ; i++)
cpnd_intrest = cpnd_intrest * i;
}
printf("the compound intrest is %f\n",cpnd_intrest);
return 0;
}
I am getting a strange output when I run the program.Kindly help.