Computer Science, asked by Chestaj, 1 day ago

WAP to accept the value for principal, rate, time and calculate simple interest and total amount. Print the Simple Interest and Total Amount with two line gap.​
It’s a c++ program

Answers

Answered by Ronithreddy
0

Answer:

#include <stdio.h>

 

int main()

{  

float principle, rate, sinterest;

int time;

 

printf("Enter Principle Amount, Rate %% per Annum and Time\n");

scanf ("%f %f %d", &principle, &rate, &time);

 

sinterest = (principle * rate * time)/ 100.0;

 

printf ("Principle Amount = %5.2f\n", principle);

printf ("Rate %% per Annum   = %5.2f%\n", rate);

printf ("Time   = %d years\n", time);

printf ("Simple Interest  = %5.2f\n", sinterest);

}

Explanation:

This program will calculate the value of the SI where the principal, rate and the time is given by the user. So first of all, you have to include the stdio header file using the "include" preceding # which tells that the header file needs to be process before compilation, hence named preprocessor directive. There is also another header file conio.h, which deals with console input/output and this library is used here for getch() function.

Then you have to define the main() function and it has been declared as an integer so by default it returns the integer. Inside the main() function you have to declare floating type variables name 'principle', 'rate', 'sinterest'; Moreover, you have to take another integer type variable name 'time'. Now, use printf() to display the message: "Enter Principle Amount, Rate %% per Annum and Time". Then the scanf() method is used which will take three values from the user and store it into variables - principal, rate and time.

Answered by ameyasgupta
0

#include <stdio.h>

int main() {

float principle, time, rate, SI;

/* Input principle, rate and time */

printf("Enter principle (amount): ");

scanf("%f", &principle);

printf("Enter time: ");

scanf("%f", &time);

printf("Enter rate: ");

scanf("%f", &rate); /* Calculate simple interest */

SI = (principle * time * rate) / 100;

printf("Simple Interest = %f", SI);

return 0;

}

Similar questions