Video Tutorial illustrating: C Program To Calculation of Simple Interest.
Header File:
#include
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
Full Source code to calculate simple interest in C program:
#include
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