Assume that a program contains the following declarations ch
Assume that a program contains the following declarations:
char c = \'\\1\';
short s=2;
int i=-3;
float f=6.5f;
double d=7.5
Give the the type of each expression listed below:
1) c*i 2) f/c 3) d/s 4) f-d
(a) char float double float
(b) int char shot double
(c) int float double double
(d) None of above
Solution
1) c * i 1 * -3 Value = -3 Type = int
char c = \'\\1\' denote number 1 so 1 * -3 is -3
2) f / c 6.5 / 1 Value = 6.5 Type = float
here the result is converted to float
3) d / s 7.5 / 2 Value = 3.25 Type = double
here the result is converted to double
4) f - d 6.5 - 7.5 Value = -1.0 Type = double
here the result is converted to double
Answer is :
(c) int float double double
