Variables
- Which of the following declaration is not supported by C?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
It is legal in Java, but not in C.
- Will the following C code compile without any error?
#include <stdio.h>
int main()
{
int n;
{
int n;
for (n = 0; n < 12; n++);
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
There can be blocks inside the block. But within a block, variables have only block scope.
- Will the following C code compile without any error?
#include <stdio.h>
int main()
{
for (int n = 0; n < 5; n++);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Compilers implementing C90 do not allow this, but compilers implementing C99 allow it.
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
k = 23;
printf("%d\n", k++);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
Variable k is not defined.
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
const int k = 11;
int *p = &k;
*p = 22;
printf("%d\n", k);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Changing const variable through non-constant pointers invokes compiler warning.