I am making a program to compute simple interest. P*R/100

this is what i have done... Please tell me whats wrong

int main() 
{ 
int p,n,count; 
float r,si; 

count=1; 
while(count<=3) 
{ 
printf("\n enter values of p,n,andr"); 
scanf("%d %d %f",&p, &n, &r); 
si=(float)p * (float)n * r / 100; 
printf("simple interest =rs. %f",si); 
count=count+1; 
} 

return(0); 
}

I am making a program to compute simple interest. P*R/100

this is what i have done... Please tell me whats wrong

int main() 
{ 
int p,n,count; 
float r,si; 

count=1; 
while(count<=3) 
{ 
printf("\n enter values of p,n,andr"); 
scanf("%d %d %f",&p, &n, &r); 
si=(float)p * (float)n * r / 100; 
printf("simple interest =rs. %f",si); 
count=count+1; 
} 

return(0); 
}

We're not in the guessing game here - so how about giving us a hand and telling us what you think is wrong.

For one, if your code snippet is meant to be a full posting of code, then you are missing the include directive for stdio.h. I'm not sure why you have the loop in place. Your code style needs a bit of work. Other than that the "dinky" little piece of code seems to work OK for me.

you need to enter the like this (p*n*r)/100 to get the simple intrest coz ur code reduces the rate of intrest since it is r/100 and not pnr/100

int main()	{
	float principle, rate, n ,interest;
	int count = 0;
	while(++count <= 3)	{
		printf("\nPlease enter the principle, rate and number: ");
		scanf("%f %f %f", &principle, &rate, &n);
		interest = (principle * rate * n) / 100;
		printf("%f", interest);
	}
}

Shouldn't all the variable except count be floats? Because you can have a principle of 100.54 and n could also be 10.5 etc. Also why are you looping through 3 times?

Edited 6 Years Ago by bulger2503: n/a

This article has been dead for over six months. Start a new discussion instead.