Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me to find the right answer: 1. The scope of a variable declared ins

ID: 2246451 • Letter: P

Question

Please help me to find the right answer:

1. The scope of a variable declared inside of a function is:

a) Local - within that function

b) Within that file only

c) global

2. The scope of a variable declared within a for() loop is:

a) Only known within the for() loop

b) Global across all functions in the file containing the code

c) Local to the function containing the for() loop

d) It depends on the variable type

3. Which of the following declares a character string of length 15 but does NOT initialize it?

a) char string1[15];

b) char[] = 15;

c) char[15];

d) char string1[] = “123451234512345”;

Explanation / Answer

1. The scope of a variable declared inside a function is always LOCAL to that function. No other function can access that variable. Answer is A

2. When a variable is declared inside a for loop, only the code from the for loop can access that variable. Answer is A) It is only known within the for loop

3. char strign1[15] is a declaration of the array of characters of length 15. But it is not initialized. So, answer is A