Simple and Compound interest by using SWITCH in C

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int p,r,t,option;
float result;
clrscr();
printf(“PRINCIPAL, TIME & RATE\n”);
scanf(“%d%d%d”,&p,&t,&r);
printf(“Enter 1 for SI, 2 for CI\n”);
scanf(“%d”,&option);
switch(option)
{
case 1:result=(p*t*r)/100.0;
break;
case 2:result=p*pow(1+r/100.0,t)-p;
break;
}
printf(“Interest=%f”,result);
getch();
}

After Running Program- 🙂

Leave a Reply