हिंदी

Suppose x and y are two double-type variables that you want to add as integer and assign to an integer variable. Construct a C++ statement to do the above.

Advertisements

प्रश्न

Suppose x and y are two double-type variables that you want to add as integer and assign to an integer variable. Construct a C++ statement to do the above.

कोड लेखन
Advertisements

उत्तर

double x, y;
int sum;
x = 12.64;
y = 13.56;
sum = (int) x + (int) y;
The variable sum will have a value of 25 due to explicit casting.

shaalaa.com
Variables of Built-in-data Types
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 9: Introduction to C++ - Data Types, Variables and Expressions - Evaluation - Section - B [पृष्ठ १५१]
Advertisements
Share
Notifications



      Forgot password?
Use app×