This blog is under construction

Monday, 10 June 2013

C program to calculate Simple Interest

Write a C program to calculate Simple Interest.



  /* C program to calculate simple interest */
  #include <stdio.h>
  int main() {
        float p, n, r, SI;
        printf("Principal:");
        /* get principal from the user */
        scanf("%f", &p);

        printf("No of years:");
        /* get year input from user */
        scanf("%f", &n);

        printf("Rate of interest:");
        /* get rate of interest from user */
        scanf("%f", &r);

        /* calculate simple interest */
        SI = (p * n * r) / 100;
        /* print the calculated simple interest value */
        printf("Simple Interest: %.2f\n", SI);
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  Principal:1000
  No of years:10
  Rate of interest:3
  Simple Interest: 300.00





See Also:

No comments:

Post a Comment