fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main()
  4. {
  5. int p,t,r,si,ci,y;
  6. int choice;
  7. printf("\n1.simple interest\n");
  8. printf("\n2.compound interest\n");
  9. printf("enter your choice");
  10. scanf("%d",&choice);
  11. printf("enter p,t,r values");
  12. scanf("%d%d%d",&p,&t,&r);
  13. switch (choice)
  14. {
  15. case 1:si=(p*t*r)/100;
  16. printf("simple interest is %d",si);
  17. break;
  18. case 2:ci=p*(pow((1+(r/100)),t)-1);
  19. printf("compound interest is %d",ci);
  20. break;
  21. default:printf("calculation not possible");
  22. break;
  23. }
  24. }
  25.  
  26.  
Success #stdin #stdout 0s 2172KB
stdin
1
1000
10
5
stdout
1.simple interest

2.compound interest
enter your choiceenter p,t,r valuessimple interest is 500