निम्नलिखित Arduino कोड का आउटपुट क्या होगा?
What will be the output of the following Arduino code ?
void main() {
int k = 0;
double d = 10.21;
printf(“%lu”, sizeof(k + d));
}
void loop() {}
A
10.21
B
8
C
null
D
23
Explanation
The given Arduino code is:
void main() {
int k = 0;
double d = 10.21;
printf("%lu", sizeof(k + d));
}
void loop() {}
Explanation:
-
int k = 0; double d = 10.21;:kis an integer, anddis a double.
-
sizeof(k + d):- In the expression
k + d,kis promoted todoublebecause arithmetic operations between integers and doubles result in adoubletype. - The result of
k + dwill be a double.
- In the expression
-
sizeof(k + d):- The
sizeofoperator returns the size of the resulting type of the expression. - Since the result of
k + dis adouble, and the size of adoubleis 8 bytes on most systems,sizeof(k + d)will return 8.
- The
Correct Answer:
(B) 8
Correct Answer: B) 8