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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started