Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to compute simple interest

Posted By: Lurleen Fischer     Category: C Programming     Views: 5144

Write a program to compute simple interest.

Code for Program to compute simple interest in C Programming

#include<stdio.h>

void main()
{
    float amount,interest,rate_int,new_amount;
    int period,year;
    rate_int=0.9;

    printf("Amount =>");
    if(scanf("%f",&amount)==1)
    {
        printf("Period");
        if(scanf("%d",&period)==1)
        {
        
            for(year=0;year<=period;year++)
            {
            printf("%9.2f\t ",amount);
            interest=amount*rate_int;
            new_amount=amount+interest;
            amount=new_amount;
            printf("%2d\t %9.2f\n",year,new_amount);
            }
                  printf("The new amount is Rs.  %0.2f",new_amount);
        }
        else
        {
            printf("error,enter correct value");
        }

    }
    else
    {
        printf("error,enter correct value");
    }
    
}
===========================================OUTPUT========================
Amount =>12000
Period =>5
 12000.00         0       22800.00
 22800.00         1       43320.00
 43320.00         2       82308.00
 82308.00         3      156385.20
156385.20         4      297131.88
297131.88         5      564550.56
The new amount is Rs.  564550.50
  
Share: 


Didn't find what you were looking for? Find more on Program to compute simple interest Or get search suggestion and latest updates.

Lurleen Fischer
Lurleen Fischer author of Program to compute simple interest is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!