/*
* @topic T00017 Feb 14, 2013 -- C++ expressions
* @brief Converting double to int
*/
#include <iostream>
int main()
{
double dbl = 0.7;
// Adding 0.5 guarantees that rounding to the
// nearest whole number takes place
int dummy = dbl + 0.5;
if ( dummy ) {
std::cout << "dummy is not zero" << "\n";
} else {
std::cout << "dummy is zero" << "\n";
}
return 0;
}
/*Program Output:
dummy is not zero
*/