Programming Examples

Calculate the total interest


Calculate the total interest based on the following.

PRINCIPLE AMOUNT (Rs.) Rate of Interest (Rs.)
>=10000 20%
>=8000 && <=9999 18%
<8000 16%

Solution

void main()
{
float princ,nyrs,rate,interest;
clrscr();
printf(“\n Enter Loan & No. of years :-”);
scanf(“%f %f”, &princ, &nyrs);
if(princ>=10000)
rate=20;
else
if(princ>=8000 && princ<=9999)
rate=18;
else
if(princ<8000)
rate=16;
interest = princ * nyrs * rate/100;
printf(“\nYears : %6.2f”,nyrs);
printf(“\nLoan : %6.2f”,princ);
printf(“\nRate : %6.2f”,rate);
printf(“\nInterest : %6.2f”,interest);
getche();
}
Output

Enter Loan & No. of years :- 5000 3

Loan : 5000.00

Years : 3.00

Rate : 16.00

Interest : 2640.00


Explanation:

In the above program, the loan and the number of years are entered through the keyboard. The entered principal amount is checked with the if statement. Based on the principal amount, the rate of interest is charged. The interest is calculated by considering different factors such as loan amount, the number of years and the rate of interest as per the table

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz