write a program to enter the principle time rate calculate the simple interest and print the simple interest and amount
Answers
Answer:
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.
Answer:
his 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.
Then according to the formula of simple inerest, the multiplicative value of all three i.e. (principal * rate * time) gets divided with 100.0 and is stored in the variable 'sinterest'.
Then all the four values i.e. principal, rate and time along with the calculated value of simple interest gets displayed using four printf() statements. The getch() reads a single byte character from input and getch() is a proper way to fetch a user inputted character.