C program for calculate simple interest.

C program for calculate simple interest
/*C program for calculate simple interest*/
#include<stdio.h>
#include<conio.h>
void 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);
 si=(p*time*rate)/100;     /*calculating simple interest*/
 printf("\nSimple Interest = %f",si);
 getch();
}

Expected Output :-

Enter principal amount : 1000
Enter rate of interest : 2
Enter time period in  year : 1
Simple Interest =20
OR
/*C program for calculate simple interest*/
#include<stdio.h>
#include<conio.h>
 void main()
{
   int amount, rate, time, si;

   printf("\nEnter Principal Amount : ");
   scanf("%d", &amount);

   printf("\nEnter Rate of Interest : ");
   scanf("%d", &rate);

   printf("\nEnter Period of Time   : ");
   scanf("%d", &time);

   si = (amount * rate * time) / 100;
   printf("\nSimple Interest : %d", si);

   getch();
}
Expected Output :

Enter Principal Amount : 500
Enter Rate of interest : 5
Enter Period of Time   : 2

Simple Interest : 50

Post a Comment

Previous Post Next Post