The duration for which the variable retains a given value during the execution of a program.
The portion of a program in which the variable may be visible.
Internal linkage of a variable.
External linkage of a variable.
Which is not a storage class?
Auto
Struct
Typedef
Static
extern int s; int t; static int u; main() {
}
Which of s, t and u are available to a function present in another file?
Only s
S & u
S, t, u
None
Which of the following statement are correct?
(i) The value stored in the CPU register can always be accessed faster than that stored in memory. (ii) A register storage class variable will always be stored in a CPU register.
Only I is correct
Only II is correct
Both I & II are correct
Both I & II are incorrect
What is the output of the following program?
#include< stdio.h>
int main() { static int a = 3; printf(“%d”, a --); return 0; }
0
1
2
3
Which of the following statement are correct?
(iii) The maximum value a variable can hold depends upon its storage class. (iv) By default all variables enjoy a static storage class.
Only I is correct
Only II is correct
Both I & II are correct
Both I & II are incorrect
What will be the output of the following program?
#include< stdio.h>
void fun() { fun(); Return 0; } void fun() { auto int I = 1; register char a = ‘D’; static int p = 0; printf(“%d %d %ld”, I, a, p); }
1 D 0
1 0 0
0 D 1
1 68 0
What will be the output of the following program?
#include < stdio.h>
static int y = 1; int main() { static int z; printf(“%d %d”, y, z); return 0; }
Garbage value
0 0
1 0
1 1
What will be the storage class of variable I in the code written below?
#include< stdio.h>
int main() { int I = 10; printf(“%d”, i); return 0; }
Automatic storage class
Extern storage class
Static storage class
Register storage class
What will be the output of the following code?
static int I = 5;
main() { int sum = 0 do { sum + = (1/i); }while(0 < I - -); printf(“sum of the series is %d”, sum); }
It will print the sum of the series 1/5+1/4+…+1/1.
It will produce a compilation error.
It will produce a run time error
None.
In case of a conflict between the names of a local and global variable what happens?
The global variable is given a priority.
The local variable is given a priority.
Which one will get a priority depends upon which one is defined first.
The compiler reports an error.
What will be the output of the following program?
#include< stdio.h>
int main() { static unsigned int a = 23; register unsigned char c = ‘R’; auto long unsigned q = 345L; static long signed p = 345L; printf(“a = %u c = %c”, a ,c); printf(“\nq = %ld p = %ld”, q, p); return 0; }
a=23 c=R q = 345 p = 345
A=23 c=R 0 0
Garbage value
A=23 c=R q = 345 p = 345
What will be the output of the following program?
#include< stdio.h>
int main() { register int I = 2; static char ch = ‘A’; auto float j; int k; k = ++ch && I; k = ++ch; j = i-- + ++k * 2; printf(“%d %f”, k , j); return 0; }
B 3
65 138.000000
68 138.000000
A 138
What will be the output of the following program?
#include< stdio.h>
Void f(static int*, extern int); Static int b = 12; Int main() { Static int a[5]; Register int I; For(I = 0; I < 2; I ++); A[i++] = 2 * i++; F(a, b); For(I = 0; I < 2; I ++) Printf(“%d”, b++); Return 0; } Void f (static int *x, extern int y) { Register int I; For(I = 0; I < 2; I ++) *(++x +1) + = 2; Y + = 2; }
0 0
0 6
0 12
12 12
Where will the space be allocated for an automatic storage class variable?
In CPU register
In memory as well as in CPU register
In memory
On disk.
What will be the output of the following code?
#include< stdio.h>
int main() { extern int a; static char j = ‘E’; printf(“%c %d”, ++j, ++a); return 0; }
E 2
F 1
F Garbage
F 0
For which of the following situation should the register storage class be used?
For local variable in a function
For loop counter
For collecting values returned from a function
For variables used in a recursive function
Which of the following statement is correct?
(i) A function can also be declared as static. (ii) The default value of an external storage class variable is zero.
Only I is correct
Only II is correct
Both I & II are correct
Both I & II are incorrect
Which of the following statement is correct about the code snippet given below?
#include < stdio.h>
extern int p; int sum = 5; int main() { p = bomb(); printf(“%d %d”, sum, p); return 0; } bomb() { sum ++; return (sum); }
The code reports an error as expression syntax
The code gets compiled successfully but will not give any output
The code gets compile successfully but will not give any output
The code gives an output as 10 20
Output?
#include <stdio.h> int main() { int x = 1, y = 2, z = 3; printf(" x = %d, y = %d, z = %d \n", x, y, z); { int x = 10; float y = 20; printf(" x = %d, y = %f, z = %d \n", x, y, z); { int z = 100; printf(" x = %d, y = %f, z = %d \n", x, y, z); } } return 0; }
x = 1, y = 2, z = 3 x = 10, y = 20.000000, z = 3 x = 1, y = 2, z = 100
Compiler Error
x = 1, y = 2, z = 3 x = 10, y = 20.000000, z = 3 x = 10, y = 20.000000, z = 100
x = 1, y = 2, z = 3 x = 1, y = 2, z = 3 x = 1, y = 2, z = 3
Predict the output
#include <stdio.h> int var = 20; int main() { int var = var; printf("%d ", var); return 0; }
Garbage Value
20
Compiler Error
Runtime error
Predict the output. #include <stdio.h> extern int var; int main() { var = 10; printf("%d ", var); return 0; }
Compiler Error: var is not defined
20
0
Runtime error
Output?
#include <stdio.h> extern int var = 0; int main() { var = 10; printf("%d ", var); return 0; }
Compiler Error: var is not defined
0
10
Runtime error
Output?
int main() { { int var = 10; } { printf("%d", var); } return 0; }
10
Compiler Error
Runtime error
Garbage Value
Output?
#include <stdio.h> int main() { int x = 1, y = 2, z = 3; printf(" x = %d, y = %d, z = %d \n", x, y, z); { int x = 10; float y = 20; printf(" x = %d, y = %f, z = %d \n", x, y, z); { int z = 100; printf(" x = %d, y = %f, z = %d \n", x, y, z); } } return 0; }
x = 1, y = 2, z = 3 x = 10, y = 20.000000, z = 3 x = 1, y = 2, z = 100
Compiler Error
x = 1, y = 2, z = 3 x = 10, y = 20.000000, z = 3 x = 10, y = 20.000000, z = 100
x = 1, y = 2, z = 3 x = 1, y = 2, z = 3 x = 1, y = 2, z = 3
Output? int main() { int x = 032; printf("%d", x); return 0; }
32
0
26
50
Consider the following C program, which variable has the longest scope?