What would be the wrong line in this program? [code] void setup() { int i; for(i=0;i<10;i++) { int a=10; a=9;

Thành Đạt

New member
What would be the wrong line in this program?
Code:
void setup() {
    int i;
    for(i=0;i<10;i++) {
        int a=10;
        a=9;
        break;
    }
    Serial.begin(9600);
    Serial.println(a);
}
A. 1
B. 3
C. 7
D. 9
 
Answer: C
Explanation: In the code above, the line 9 is wrong since it refers to a variable ‘a’ that was declared and initiated inside the scope of the for loop and so inaccessible to the rest of the variables inside the function setup() but outside the loop.
 

Tìm kiếm

Back
Top