ch1-Increment (int and float)
Chapter_1 Truncate |
Increment.cpp
#include <iostream>
using std::cout;
using std::endl;
int main()
{
double d1 = 1.6, d2 = 1.7;
cout << "d1 = " << d1 << ", d2 = " << d2 << endl;
d1++; // works for floats too (not just for integers)
d2 += 2.1; // can use fractional values too, not just integral values
cout << "d1 = " << d1 << ", d2 = " << d2 << endl;
return 0;
}
/*
g++ Increment.cpp -o Increment
./Increment
d1 = 1.6, d2 = 1.7
d1 = 2.6, d2 = 3.8
*/
Chapter_1 Truncate | BACK_TO_TOP |
Comments
Post a Comment