C++ int type and float type Calculate interest

Description

C++ int type and float type Calculate interest

#include <stdio.h>
int main()/*from  ww w .  j  a  va2 s.c  o m*/
{
   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;
}



PreviousNext

Related