Tuesday 1 March 2016

Simple interest

Q. Write an interactive program to calculate simple interest.

Ans.

#include<stdio.h>
#include<conio.h>
int main()
{
 float p,rate,time,si;
 printf("Enter principal amount : ");
 scanf("%f", &p);
 printf("Enter rate of interest : ");
 scanf("%f", &rate);
 printf("Enter time period in  year : ");
 scanf("%f", &time);
/*calculating simple interest*/
 si=(p*time*rate)/100;
 printf("\nSimple Interest = %2f",si);
 getch();
 return 0;

}

Output:

Enter principal amount : 1000
Enter rate of interest : 2
Enter time period in  year : 1

Simple Interest =20

No comments:

Post a Comment

Ads Inside Post