Program to calculate the simple interest using while loop

    /* Program : The while loop */
    #include <iostream.h>
    void main( )
    {
        float principle , rate_of_interest , no_of_years ;
        int num = 0 ;
        float simple_interest ;

        cout<<"Simple Interest Calculation : ";

        while (num<2)
        {
            cout<<"\nSet  - "<<num+1;
            cout<<"Enter the principle value : ";
            cin>>principle;
            cout<<"Enter the rate of interest : " ;
            cin>>rate_of_interest;
            cout<<"Enter the number of years : ";
            cin>>no_of_years;

    simple_interest = (principle * rate_of_interest * no_of_years) ;
            simple_interest = simple_interest / 100 ;

    cout<<"The simple interest is : "<<simple_interest;

            num++ ;
        }
    }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|