WAP that calculates the simple interest and compound interest. The principal amount, rate of interest and time are entered through the keyboard.

 Here is your code :-

#include <stdio.h>
#include <math.h>
// used for pow function used in compound_Interest formula.

int main()
{
   
// Initialisation of variables.
    float simple_Interest, compound_Interest, principle,                rate_of_interest, time;
    
    printf("Enter the Principal amount, rate of Interest and time:     ");
    
   
// Taking Input for principle amount, rate_of_interest and time.
    scanf("%f%f%f", &principle, &rate_of_interest, &time);
    
   
// Using formula to find simple_Interest.
    simple_Interest = (principle * rate_of_interest * time) / 100;

    // Using formula to find compound_Interest.
    compound_Interest =  principle * pow((1 + rate_of_interest/100),     time);
    
   
// printing the simple_Interest and compound_Interest found.
    printf("The Simple Interest is : %f and compound interest is %f",     simple_Interest, compound_Interest);

    return 0;
}

Output:- 


 

Explanation:- 

 Math.h library is used because we had used pow() function in Compound Interest Formula.

1. Intialisation of variables used.

2. Printing Statement of asking Input.

3. Taking Input of required Variables.

4.Used formula for both seperately.

5. Printing the results. 



Comments

Popular posts from this blog

WAP to add or to multiply two matrices of order nXn.

WAP that inputs two arrays and saves sum of corresponding elements of these arrays in a third array

WAP to find the minimum and maximum element of the array by using functions.