Simple Interest: C Program

Advertisement:


Video Tutorial illustrating: C Program To Calculation of Simple Interest.

Header File:

   #include<stdio.h>

To be able to use printf function, we have to include stdio.h header file.

main()
This is the starting point of C program execution.
since it does not return any value, we write void main()

Declaration of Variables:

   	int p, n;
	float r, si;

variables p and n are integer type variables i.e., they can hold integer values.
variables r and si are float or real type variables i.e., they can hold fractional values.

   clrscr();

to clear the output screen.

Initialization of Variables:

   	p = 1000;
	n = 3;
	r = 8.5;

Principle p = 1000
n or time or duration = 3
rate of interest r = 8.5

Formula to calculate simple interest:

     si = ( p * n * r ) / 100;

The mathematical formula si = ( p x n x r ) / 100; is written as si = ( p * n * r ) / 100;

Output statement:

	printf("%f\n",si);

the function printf is present inside stdio.h header file. %f is formatting string for float or real type values.

	getch();

function to return to the console window.

Video Tutorial: C Program to calculate Simple Interest



YouTube Link: http://www.youtube.com/watch?v=TGgd6KvL_W0 [Watch the Video In Full Screen.]



Full Source code to calculate simple interest in C program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
 
void main()
{
 
	int p, n;
	float r, si;
 
	clrscr();
 
	p = 1000;
	n = 3;
	r = 8.5;
 
	si = ( p * n * r ) / 100;
 
	printf("%f\n",si);
 
	getch();
}

Output:
255.000000


Related posts:







Get FREE blog updates to your email inbox. Enter your email ID and subscribe:


Do not forget to click the verification link in your email, after subscribing.
--Thanks for your support

Start Making Money From Your Programming Skills


( Free ebook )
ebook cover
  • Subscribe to Technotip.com blog update and you will be able to download "Tips, Tricks and Strategies to Make Money Online" eBook for free.
  • You will also receive tips to improve your programming skills, and strategies to make money from your programming skills. We will also send useful resources for learning and building your application.
  • You can also make money with us, by just recommending our website to your friends and family. You will get complete strategy for making $300 and more in the ebook that we will send you - once you subscribe to our free blog update using the below form..

Leave a Reply