C Storage Classes - placement questions answers

C Storage Classes - placement questions answers


1. Longevity of a variable refers to

a) The duration for which the variable retains a given value during the execution of a program.
b) The portion of a program in which the variable may be visible.
c) Internal linkage of a variable.
d) External linkage of a variable.

View Answer / Hide Answer

ANSWER: A




2. Which is not a storage class?

a) Auto
b) Struct
c) Typedef
d) Static

View Answer / Hide Answer

ANSWER: B




3. extern int s;

int t;
static int u;
main()
{

}

Which of s, t and u are available to a function present in another file?

a) Only s
b) S & u
c) S, t, u
d) None

View Answer / Hide Answer

ANSWER: A




4. 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.

a) Only I is correct
b) Only II is correct
c) Both I & II are correct
d) Both I & II are incorrect

View Answer / Hide Answer

ANSWER: A




5. What is the output of the following program?

#include <stdio.h>
int main()
{
static int a = 3;
printf(“%d”, a --);
return 0;
}

a) 0
b) 1
c) 2
d) 3

View Answer / Hide Answer

ANSWER: 3




6. 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.

a) Only I is correct
b) Only II is correct
c) Both I & II are correct
d) Both I & II are incorrect

View Answer / Hide Answer

ANSWER: D




7. 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);
}

a) 1 D 0
b) 1 0 0
c) 0 D 1
d) 1 68 0

View Answer / Hide Answer

ANSWER: D




8. 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;
}

a) Garbage value
b) 0 0
c) 0 1
d) 1 1
View Answer / Hide Answer

ANSWER: C



Post your comment