C++ Data Type mixed in an expression, mix int and float type value

Description

C++ Data Type mixed in an expression, mix int and float type value

#include <stdio.h>
int main()//  w ww .  j av a  2  s.c o m
{
   int bonus=50;
   float salary=1400.50;
   float total;
   total=salary+bonus;  // bonus becomes floating-point
   // but only temporarily.
   printf("The total is %.2f", total);
   return 0;
}



PreviousNext

Related