Question: Please help...thank you. C/C++ Programming Note : To complete this homework you may need to use C/C++ features that are not covered in the lab

Please help...thank you.

C/C++ Programming

Note: To complete this homework you may need to use C/C++ features that are not covered in the lab sessions or lectures. To find the answer to each question, you can either use deduction or implement and run the code.

Exercise 2 (5 pts) [Scope of Variables]. We talked about the scope of a variable in class. Read the following code and answer the questions.

1 #include <stdio .h>

2

3 int main( int argc , char argv)

{ int a = 5;

{

int a = 3;

printf(%d , a) ;

9 printf(%d , a) ;

return 1;

}

What will be displayed by each of the printf?

If a variable is declared before the main function, it is called a global variable; and it then can be used without declaring again in main. Read the following code and answer the question.

1 #include <stdio .h>

2

3 int a = 5;

4

5 int main( int argc , char argv) {

6 printf(%d , a) ;

7 int a = 3;

8 printf(%d , a) ;

9 return 1;

10 }

What will be displayed by each of the printf?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!