🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित 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)
B)
C)
D)

Explanation:

The given Arduino code is:

void main() {
    int k = 0;
    double d = 10.21;
    printf("%lu", sizeof(k + d));
}

void loop() {}

Explanation:

  1. int k = 0; double d = 10.21;:

    • k is an integer, and d is a double.
  2. sizeof(k + d):

    • In the expression k + d, k is promoted to double because arithmetic operations between integers and doubles result in a double type.
    • The result of k + d will be a double.
  3. sizeof(k + d):

    • The sizeof operator returns the size of the resulting type of the expression.
    • Since the result of k + d is a double, and the size of a double is 8 bytes on most systems, sizeof(k + d) will return 8.

Correct Answer:

(B) 8

Latest Updates