Q20 When interest compound q times per year at an annual rate of r % for n years, the principal p compounds to an amount a as per the following formula a=p(1+r/q)^nq Write a program to read 10 sets of p, r, n & q and calculate the corresponding as.

Write a program to read 10 sets of p, r, n & q and calculate the corresponding as.

Program: 112

When interest compound q times per year at an annual rate of r % for n years, the principal p compounds to an amount a as per the following formula:

a=p(1+r/q)nq

Write a c program to read 10 sets of p, r, n & q and calculate the corresponding as.

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    float p,n,r,q,a;
    int i;
    //for 10 sets we have to create a for loop
    for(i=1;i<=10;i++)
    {
        printf("Set: %d\n",i);
        //accept the values from user
        printf("Enter Principle: ");
        scanf("%f",&p);
        printf("Enter Rate: ");
        scanf("%f",&r);
        printf("Enter Time(in year): ");
        scanf("%f",&n);
        printf("Enter Compound Interest: ");
        scanf("%f",&q);

        //formula
        a = p*(pow((1+r/q),n*q));
        printf("Amount: %.2f\n\n",a);
    }
}

Output:

Set: 1
Enter Principle: 1000
Enter Rate: 10
Enter Time(in year): 1
Enter Compound Interest: 1
Amount: 11000.00

Set: 2
Enter Principle: 2000
Enter Rate: 10
Enter Time(in year): 1
Enter Compound Interest: 1
Amount: 22000.00

Set: 3
Enter Principle: 100
Enter Rate: 1
Enter Time(in year): 1
Enter Compound Interest: 1
Amount: 200.00

Set: 4
Enter Principle: 200
Enter Rate: 5
Enter Time(in year): 1
Enter Compound Interest: 5
Amount: 6400.00

Set: 5
Enter Principle: 622
Enter Rate: 2
Enter Time(in year): 4
Enter Compound Interest: 1
Amount: 50382.00

Set: 6
Enter Principle: 200
Enter Rate: 1
Enter Time(in year): 1
Enter Compound Interest: 10
Amount: 518.75

Set: 7
Enter Principle: 355
Enter Rate: 45
Enter Time(in year): 1
Enter Compound Interest: 21
Amount: 9863834894336.00

Set: 8
Enter Principle: 515
Enter Rate: 5
Enter Time(in year): 1
Enter Compound Interest: 12
Amount: 33652.66

Set: 9
Enter Principle: 110
Enter Rate: 1
Enter Time(in year): 1
Enter Compound Interest: 1
Amount: 220.00

Set: 10
Enter Principle: 200
Enter Rate: 2
Enter Time(in year): 3
Enter Compound Interest: 2
Amount: 12800.00

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.