Suppose x1 and x2 are two double type variables that you want to
add as integers and assign to an integer variable. Construct a C
statement for doing so?
Answers
Answered by
7
Either of the following would work for the first task:
int pos = (int) x1 + (int) x2;
int pos = int(x1) + int(x2);
To add them as type double and then convert, you could do either of the following:
int pos = (int) (x1 + x2);
int pos = int(x1 + x2);
Similar questions