How to calculate Simple Interest in C with Algorithm



 In this post, we are going to make a Simple Interest Calculator in C. 


Algorithm

1. We write Header File in C.

2. We declare the integer as p,n.

3. We declare Float as r, si.

4. Then we declare the value of p =1000.

5. Then we declare the value of n = 3.

6. Then we declare the value of r = 8.5.

7. Now we apply the Simple Interest Formula. (p*n*r/100)

8. Then we print the final value.

(ads2)

Rules

1. // is used for comments in C. When you run code the compiler ignores the text in //.

2. printf - This function is used to show the output of the code.

3. %f - It is used when we use float in our code.

4. \n - It is used to print the text/value in the next line.

(ads1)

Code

#include <stdio.h>
int main()
//P = Principle Amount.
//N = No. Of Years.
//R = Rate Of Intrest.
//SI = Simple Intrest.

{                           //Don't forgot to add curly brackets.
int p,n;                    //Don't forgot to add semicolen. and We declare int as p,n.
float r,si;                 //We declare float as r,si.
p=1000;                     //We declare the value of p as 1000.    
n=3;                        //We declare the value of n as 3.
r=8.5;                      //We declare the value of r as 8.5.

// Now we apply our Simple Intrest Formula.
si=p*n*r/100;
printf("%f\n",si);
return 0;
}

Output

255.000000

In the next post, we are going to make a Simple Intrest Calculator and the values are taken by the user.


Video Solution/Output



Post a Comment

Previous Post Next Post