Calculate interest using int and float type - C++ Data Type

C++ examples for Data Type:float

Description

Calculate interest using int and float type

Demo Code

#include <stdio.h>
int main()//from  w ww  .  j a va  2  s  . c om
{
   int days=45;  
   float principle = 3500.00; 
   float interest_rate=0.155; 
   float daily_interest;   
   daily_interest=interest_rate/365; 

   // Because days is int, it too is converted to float.

   daily_interest = principle * daily_interest * days;

   principle+=daily_interest;

   printf("The balance you owe is %.2f\n", principle);
   return 0;
}

Result


Related Tutorials