C Programming Questions and Answers – Automatic Variables
C Programming Questions and Answers – Automatic Variables
1.The scope of an automatic variable is:
a) Within the block it appears
b) Within the blocks of the block it appears
c) Until the end of program
d) Both (a) and (b)
View Answer
2.Automatic variables are allocated space in the form of a:
a) stack
b) queue
c) priority queue
d) random
View Answer
3.Which of the following is a storage specifier?
a) enum
b) union
c) auto
d) volatile
View Answer
4.Default storage class if not any is specified for a local variable, is auto
a) true
b) false
c) Depends on the standard
d) None of the mentioned
View Answer
5.What is the output of this C code?
#include <stdio.h>
void foo(auto int i);
int main()
{
foo(10);
}
void foo(auto int i)
{
printf(“%d\n”, i );
}
a) 10
b) Compile time error
c) Depends on the standard
d) None of the mentioned
View Answer
6.Automatic variables are stored in
a) stack
b) data segment
c) register
d) heap
View Answer
7.What linkage does automatic variables have?
a) Internal linkage
b) External linkage
c) No linkage
d) None of the mentioned
View Answer
8.What is the output of this C code?
#include <stdio.h>
int main()
{
auto i = 10;
const auto int *p = &i;
printf(“%d\n”, i);
}
a) 10
b) Compile time error
c) Depends on the standard
d) Depends on the compiler
View Answer
9.Automatic variables are variables that are
a) Declared within the scope of a block, usually a function
b) Declared outside all functions
c) Declared with auto keyword
d) Declared within the keyword extern
View Answer
10.Automatic variables
a) Exist only within that scope in which it is declared
b) Cease to exist after the block is exited
c) Both a & b
d) Only 1
View Answer
11.Automatic variables are allocated memory in
a) heap
b) Data segment
c) Code segment
d) stack.
View Answer
12.What is the output of this C code?
#include <stdio.h>
void main()
{
int x;
}
here x is
a) automatic variable
b) static variable
c) register variable
d) global variable.
View Answer
13.Automatic variables are initialised to
a) Zero
b) Junk value
c) Nothing
d) Both a & b
View Answer
14.Which of the following storage class supports char data type?
a) register
b) static
c) auto
d) All of the mentioned
View Answer
15.The variable declaration with no storage class specified is by default:
a) auto
b) extern
c) static
d) register