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

C++ examples for Data Type:float

Description

Demonstrate mixed data type in an expression, mix int and float type value

Demo Code

#include <stdio.h>
int main()/*  w  w  w.j ava2  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;
}

Result


Related Tutorials