Place Your Query
-
C Programming
-
- Control flow-based C Programs
- Enjoy Conditional Programming in C using If...else and switch statement.
- Good, Now write a C program to display "Hello World" on the screen.
- Write a C program to display Your Name, Address and City in different lines.
- C program to find sum of n numbers
- Write a C program For Addition of two numbers using Function.
- Write a Program to Find Simple Interest and Compound Interest.
- Write a Program to Convert Celsius To Fahrenheit and Vice Versa.
- Write a Program to Find Area and Perimeter of Circle, Triangle, Rectangle and Square.
- Write a Program to Swap Two Numbers Using Temporary Variables and Without Using Temporary Variables
- Write a C Program to Design a Simple Menu Driven Calculator
- Simple Expression Based C Programs
-
- 7. Components of C language
- 1. Introduction to C Programming Language
- 10. Operator Precedence and Associativity
- 11. Comments in C Programming
- 14. Fundamental Control Structure Statements in C [Part-1]
- 15. Fundamental Control Structure Statements in C [Part-2]
- 16. Looping Statements [Fundamental Control Structure Statements in C. #Part-3]
- 17. Keyword break, continue, return and exit [Fundamental Control Structure Statements in C. #Part-4]
- 2. Computer Languages
- 3. Interpreters vs Compilers vs Assemblers in programming languages
- 4. C Program Structure
- 5. Compile and Execute C Program
- 6. Errors in C Program
- 8. C Datatypes
- 9. Operators in C
- Control flow-based C Programs
- Demystifying Bit Masking: Unlocking the Power of Bitwise Operators in C-Language with best Examples.
- 18. Fundamentals of C Functions
- Show Remaining Articles (3)Collapse Articles
-
-
Java
-
AI ML
-
FAQs
- A Program to find Tokens in C code?
- What are the Common Coding Mistakes.
- Easy Learning, Python QAs for Beginner’s to Pro Part-1
- Easy Learning, Python QAs for Beginner’s to Pro Part-2
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-1
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-2
- Easy Learning, Python String Functions QAs for Beginner to Pro Part-3
-
Python Interview Questions
- Easy Learning, Python QAs for Beginner’s to Pro Part-1
- Easy Learning, Python QAs for Beginner’s to Pro Part-2
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-1
- Easy Learning, Python Strings QAs for Beginner’s to Pro Part-2
- Easy Learning, Python String Functions QAs for Beginner to Pro Part-3
Write a Program to Find Simple Interest and Compound Interest.
Aim
This type of expression-based programs are supposed to be basic c-program, where user gives some inputs like for principal amount as p, time as n years and rate of interest as r. Finally, using the mathematical formula as expression will help in writing a C program to find the Simple Interest and Compound Interest.
Procedure/ Algorithm
Step-1: Start the program execution.
Step-2: Declare the variables p, n, r.
Step-3: Input the values for p, n, r.
Step-4: Calculate and print the values of simple interest.
OR
Step-5: Calculate and print the values of compound interest.
Step-6: Stop the program execution.
Hello WorldBlockHello World
// Program to calculate simple interest
#include<stdio.h>
#include<math.h>
int main()
{
int p,n;
float r;
printf("\nEnter the value of amount, number of years and Rate of interest:");
scanf("%d%d%f",&p,&n,&r);
float SI=(p*n*r)/100);
printf("\nThe simple interest is = %f",SI));
return 0;
} // end main
Output
Enter the value of amount, number of years and Rate of interest:
100
5
4
The simple interest is = 20.000000
--------------------------------
Process exited after 8.76 seconds with return value 0
Press any key to continue . . .
Program: Calculate the Compound Interest
// Program to calculate compound interest
#include<stdio.h>
#include<math.h>
int main()
{
int p,n;
float r;
printf("\nEnter the value of amount, number of years and Rate of interest:");
scanf("%d%d%f",&p,&n,&r);
float CI=p*pow((1+(r/100)),n)-p;
printf("\nThe compound interest is = %f",CI);
return 0;
} // end main
Output
Enter the value of amount, number of years and Rate of interest:
100
5
4
The compound interest is = 21.665268
--------------------------------
Process exited after 8.76 seconds with return value 0
Press any key to continue . . .
Run Directly on in-built C-Compiler
While using in-built C-Compiler Use Gear icon for custom Input (i.e. whenever you have to give values to read)
Result
Thus, the C program has been written, executed successfully to calculate the simple interest and compound interest.