Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ Automatic Conversion from double to int

//Working of Implicit type-conversion

#include <iostream>
using namespace std;

int main() {

   int num_int;
   double num_double = 9.99;

   // implicit conversion
   // assigning a double value to an int variable
   num_int = num_double;

   cout << "num_int = " << num_int << endl;
   cout << "num_double = " << num_double << endl;

   return 0;
}
 
PREVIOUS NEXT
Tagged: #Automatic #Conversion #double #int
ADD COMMENT
Topic
Name
4+9 =