Which line in the code snippet is wrong? [code] void setup() { int a = 0; const int b = 1; b=a; } [/code]

Which line in the code snippet is wrong?
Code:
void setup() {
    int a = 0;
    const int b = 1;
    b=a;
}
A. 2
B. 3
C. 4
D. 1
 
Answer: C
Explanation: The Line 4 is wrong because it uses the variable ‘b’ and tries to put the value of the variable ‘a’ into it. However, that is not possible since variable ‘b’ is declared a ‘const’ variable. This means once the variable is declared, it’s value cannot be changed throughout the length of the entire program.
 

Tìm kiếm

Back
Top