Variables
- Which variable has the longest scope in the following C code?
#include <stdio.h>
int p;
int main()
{
int q;
return 0;
}
int r;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
p
- What is the scope of an external variable?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
From the point of declaration to the end of the file being compiled
- What is the scope of a function?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
From the point of declaration to the end of the file being compiled
- Comment on the output of the following C code.
#include <stdio.h>
int main()
{
int k;
for (k = 0; k < 10; k++)
int m = k;
printf("%d", m);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Syntax error in declaration of m
- What will be the sequence of allocation and deletion of variables in the following C code?
#include <stdio.h>
int main()
{
int num;
{
int var;
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
num->var, var->num