Skip to content
ExamHope Logo

examhope

Primary Menu
  • Digital Logic
    • Arithmetic Operations
    • Asynchronous/Ripple Counters
    • Basic Gates
    • Boolean Algebraic Theorems
    • Codes
  • Data Structures
    • Binary Heaps
    • Binary Search
    • Binary Search Trees
    • Binary Tree
    • Binary Tree Sort
    • Bipartite Graphs
    • Complete Graph
  • Theory of Computation
    • Finite Automata
    • Finite Automaton First Example
  • Current Affairs
    • Sports News
    • Tech News
    • Bollywood News
    • Daily News
  • Database
  • Computer Network
  • Computer Organization and Architecture
  • C Language
  • Operating Systems
  • Software Engineering
  • Theory of Computation
  • About us
  • Contact Us
  • Privacy Policy
  • DMCA Policy
  • Terms and Conditions
  • Home
  • IT
  • Storage Classes MCQs in C Language
  • IT
  • C Language
  • Storage Classes

Storage Classes MCQs in C Language

examhopeinfo@gmail.com October 24, 2025 10 minutes read
Storage Classes MCQs in C Language

Storage Classes MCQs in C Language

Storage Classes C Language MCQs in C Language


1.

What is the default storage class of local variables in C?

A) static
B) auto
C) extern
D) register

โœ… Answer: B
Explanation:
Local variables are auto by default unless specified otherwise.


2.

Which storage class preserves the value of a variable between function calls?

A) auto
B) extern
C) static
D) register

โœ… Answer: C
Explanation:
static local variables retain their value across function calls.


3.

Which storage class cannot be used with arrays?

A) auto
B) register
C) static
D) extern

โœ… Answer: B
Explanation:
register suggests storing in CPU registers, which cannot hold arrays.


4.

Consider:

#include <stdio.h>
void fun() {
    static int x = 0;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

Output:

A) 0 0 0
B) 1 2 3
C) 1 1 1
D) 3 3 3

โœ… Answer: B
Explanation:
static x retains its value across calls โ†’ increments 1โ†’2โ†’3.


5.

Which storage class is used to access a variable defined in another file?

A) auto
B) extern
C) static
D) register

โœ… Answer: B
Explanation:
extern allows referencing a variable defined in another file.


6.

Identify the storage class of a variable declared outside all functions without static.

A) auto
B) extern
C) register
D) static

โœ… Answer: B
Explanation:
Global variables without static have external linkage โ†’ extern.


7.

Which storage class is generally used for local counters in loops for faster access?

A) static
B) auto
C) register
D) extern

โœ… Answer: C
Explanation:
register suggests storing in CPU register โ†’ fast access.


8.

Output:

#include <stdio.h>
int x = 5;
void fun() {
    extern int x;
    x += 2;
}
int main() {
    fun();
    printf("%d", x);
}

A) 5
B) 7
C) 2
D) Compiler error

โœ… Answer: B
Explanation:
extern int x refers to global x=5, incremented by 2 โ†’ 7.


9.

Output:

#include <stdio.h>
void fun() {
    auto int x = 0;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 0 1 2
B) 1 2 3
C) 1 1 1
D) 0 0 0

โœ… Answer: C
Explanation:
auto variable reinitializes each function call โ†’ prints 1 1 1.


10.

Which storage class has file scope but internal linkage?

A) extern
B) auto
C) static
D) register

โœ… Answer: C
Explanation:
static global variables/functions are file scope but cannot be accessed outside โ†’ internal linkage.


11.

Output:

#include <stdio.h>
void fun() {
    static int x;
    printf("%d ", x++);
}
int main() {
    fun(); fun(); fun();
}

A) 0 1 2
B) 1 2 3
C) 0 0 0
D) 1 1 1

โœ… Answer: A
Explanation:
static x initializes to 0 โ†’ increments 0โ†’1โ†’2.


12.

Which storage class cannot be initialized at declaration?

A) auto
B) static
C) register
D) extern

โœ… Answer: C
Explanation:
register variables cannot have an initializer because they are stored in CPU registers.


13.

Output:

#include <stdio.h>
int x = 10;
int main() {
    static int x = 5;
    printf("%d", x);
}

A) 10
B) 5
C) 0
D) Compiler error

โœ… Answer: B
Explanation:
Local static x=5 shadows global x=10 โ†’ prints 5.


14.

Which of the following statements is true?

A) auto variables retain value between calls
B) static variables are reinitialized on each call
C) register variables may be faster than auto
D) extern variables are local by default

โœ… Answer: C
Explanation:
register variables may reside in CPU register โ†’ faster than memory.


15.

Output:

#include <stdio.h>
int x = 3;
void fun() {
    int x = 5;
    printf("%d ", x);
}
int main() {
    fun();
    printf("%d", x);
}

A) 5 3
B) 3 5
C) 5 5
D) 3 3

โœ… Answer: A
Explanation:
Local x=5 inside fun() shadows global โ†’ prints 5; main prints global x=3 โ†’ 5 3.


16.

Output:

#include <stdio.h>
extern int x;
int main() {
    printf("%d", x);
}

A) 0
B) Garbage
C) Compiler error
D) Depends on system

โœ… Answer: C
Explanation:
extern int x; declaration without definition โ†’ linker error.


17.

Which storage class is default for global variables?

A) auto
B) register
C) extern
D) static

โœ… Answer: C
Explanation:
Global variables without static have external linkage โ†’ behave like extern.


18.

Output:

#include <stdio.h>
void fun() {
    register int x = 0;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 1 2 3
B) 1 1 1
C) 0 0 0
D) Compiler error

โœ… Answer: B
Explanation:
register variable is local โ†’ reinitialized each call โ†’ prints 1 1 1.


19.

Which storage class allows variable sharing across multiple files?

A) auto
B) extern
C) register
D) static

โœ… Answer: B
Explanation:
extern is used to access global variables defined in another file.


20.

Output:

#include <stdio.h>
void fun() {
    static int x=1;
    printf("%d ", x++);
}
int main() {
    fun(); fun(); fun();
}

A) 1 1 1
B) 1 2 3
C) 0 1 2
D) 2 3 4

โœ… Answer: B
Explanation:
static x=1 retains value โ†’ increments 1โ†’2โ†’3.

21.

Output:

#include <stdio.h>
void fun() {
    static int x;
    x += 3;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 3 3 3
B) 3 6 9
C) 0 3 6
D) 1 4 7

โœ… Answer: B
Explanation:
static x initializes to 0, retains value โ†’ 0+3=3, 3+3=6, 6+3=9.


22.

Which storage class can only be used inside a function?

A) auto
B) extern
C) static
D) register

โœ… Answer: D
Explanation:
register can only be used for local variables, not global.


23.

Output:

#include <stdio.h>
extern int x;
int x = 10;
int main() {
    printf("%d", x);
}

A) 0
B) 10
C) Compiler error
D) Garbage

โœ… Answer: B
Explanation:
extern int x; refers to global x=10 โ†’ printed.


24.

Output:

#include <stdio.h>
void fun() {
    int x = 5;
    static int y = 5;
    x++; y++;
    printf("%d %d ", x, y);
}
int main() {
    fun(); fun();
}

A) 6 6 6 7
B) 6 6 6 6
C) 5 5 6 6
D) 6 5 6 6

โœ… Answer: A
Explanation:
x is auto โ†’ reinitialized 5 each call โ†’ x+1=6; y is static โ†’ retains value โ†’ 5+1=6, next call 6+1=7.


25.

Which storage class cannot have local scope?

A) auto
B) register
C) static (global)
D) extern

โœ… Answer: D
Explanation:
extern references global variables, cannot define local variables.


26.

Output:

#include <stdio.h>
static int x = 10;
int main() {
    printf("%d", x);
}

A) 0
B) 10
C) Compiler error
D) Garbage

โœ… Answer: B
Explanation:
static global variable accessible in same file โ†’ prints 10.


27.

Output:

#include <stdio.h>
void fun() {
    static int x=0;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 0 0 0
B) 1 1 1
C) 1 2 3
D) 0 1 2

โœ… Answer: C
Explanation:
Static variable retains value โ†’ increments each call โ†’ 1 2 3.


28.

Which storage class is used for variables that should be fast-access and temporary?

A) auto
B) register
C) extern
D) static

โœ… Answer: B
Explanation:
register suggests storing variable in CPU registers โ†’ faster access.


29.

Output:

#include <stdio.h>
int x = 5;
int main() {
    static int x = 10;
    printf("%d", x);
}

A) 5
B) 10
C) 0
D) Compiler error

โœ… Answer: B
Explanation:
Local static x=10 shadows global x=5 โ†’ prints 10.


30.

Output:

#include <stdio.h>
void fun() {
    auto int x = 0;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun();
}

A) 1 1
B) 1 2
C) 0 1
D) 2 3

โœ… Answer: A
Explanation:
auto variable reinitializes each call โ†’ x=0 โ†’ x+1=1 โ†’ prints 1 1.


31.

Which storage class is default for global variables?

A) static
B) auto
C) extern
D) register

โœ… Answer: C
Explanation:
Global variables without static have external linkage โ†’ behaves like extern.


32.

Output:

#include <stdio.h>
void fun() {
    register int x=0;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun();
}

A) 1 1
B) 1 2
C) 0 1
D) Compiler error

โœ… Answer: A
Explanation:
register variable is local โ†’ reinitialized each call โ†’ prints 1 1.


33.

Output:

#include <stdio.h>
int x = 5;
void fun() {
    extern int x;
    x += 10;
}
int main() {
    fun();
    printf("%d", x);
}

A) 5
B) 10
C) 15
D) Compiler error

โœ… Answer: C
Explanation:
extern x references global x=5 โ†’ x+10=15 โ†’ printed.


34.

Which storage class restricts access to the same file only?

A) auto
B) extern
C) register
D) static

โœ… Answer: D
Explanation:
Global static variables/functions have file scope only.


35.

Output:

#include <stdio.h>
void fun() {
    static int x;
    printf("%d ", x);
    x++;
}
int main() {
    fun(); fun();
}

A) 0 1
B) 1 2
C) 0 0
D) 1 1

โœ… Answer: A
Explanation:
static x initialized to 0, increments after printing โ†’ 0 1.


36.

Output:

#include <stdio.h>
extern int y;
int y = 20;
int main() {
    printf("%d", y);
}

A) 0
B) 20
C) Compiler error
D) Garbage

โœ… Answer: B
Explanation:
extern y refers to global y=20 โ†’ printed.


37.

Output:

#include <stdio.h>
int main() {
    auto int x = 5;
    x++;
    printf("%d", x);
}

A) 5
B) 6
C) 0
D) Compiler error

โœ… Answer: B
Explanation:
auto x=5 โ†’ x++ โ†’ 6 โ†’ printed.


38.

Output:

#include <stdio.h>
void fun() {
    static int x = 1;
    x *= 2;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 1 2 4
B) 2 4 8
C) 1 1 1
D) 2 2 2

โœ… Answer: B
Explanation:
Static x=1 โ†’ x2=2, next call 22=4, next 4*2=8 โ†’ prints 2 4 8.


39.

Which storage class cannot have memory address accessed using & operator?

A) auto
B) register
C) static
D) extern

โœ… Answer: B
Explanation:
register variables may not have memory address accessible โ†’ cannot use &.


40.

Output:

#include <stdio.h>
void fun() {
    static int x = 3;
    printf("%d ", x);
    x++;
}
int main() {
    fun(); fun(); fun();
}

A) 3 3 3
B) 3 4 5
C) 4 5 6
D) 3 2 1

โœ… Answer: B
Explanation:
Static x=3 โ†’ increments each call โ†’ 3 4 5.

41.

Output:

#include <stdio.h>
void fun() {
    auto int x = 2;
    x *= 2;
    printf("%d ", x);
}
int main() {
    fun(); fun();
}

A) 2 4
B) 4 8
C) 4 4
D) 2 2

โœ… Answer: C
Explanation:
auto variable is local โ†’ reinitializes to 2 each call โ†’ x*2=4 each time โ†’ prints 4 4.


42.

Output:

#include <stdio.h>
int x = 5;
void fun() {
    static int x = 2;
    x += 3;
    printf("%d ", x);
}
int main() {
    fun(); fun();
    printf("%d", x);
}

A) 5 8 5
B) 5 5 5
C) 5 5 8
D) 5 8 8

โœ… Answer: A
Explanation:
static x=2 inside function โ†’ 2+3=5, next call 5+3=8 โ†’ prints 5 8; global x=5 โ†’ printed at end.


43.

Which storage class allows a variable to retain its value between function calls but restricts scope to the file?

A) extern
B) auto
C) register
D) static

โœ… Answer: D
Explanation:
static variable has internal linkage โ†’ scope limited to file but retains value.


44.

Output:

#include <stdio.h>
extern int x;
int x = 10;
int main() {
    extern int x;
    x += 5;
    printf("%d", x);
}

A) 10
B) 5
C) 15
D) Compiler error

โœ… Answer: C
Explanation:
extern x refers to global x=10 โ†’ incremented by 5 โ†’ 15.


45.

Which storage class is generally used for frequently accessed loop variables?

A) auto
B) static
C) register
D) extern

โœ… Answer: C
Explanation:
register variables may be stored in CPU registers โ†’ faster access.


46.

Output:

#include <stdio.h>
void fun() {
    static int x;
    printf("%d ", x);
    x++;
}
int main() {
    fun(); fun(); fun();
}

A) 0 1 2
B) 1 2 3
C) 0 0 0
D) 1 1 1

โœ… Answer: A
Explanation:
Static x initializes to 0, retains value โ†’ prints 0 1 2.


47.

Output:

#include <stdio.h>
void fun() {
    auto int x = 1;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 1 2 3
B) 2 2 2
C) 2 3 4
D) 1 1 1

โœ… Answer: B
Explanation:
auto variable reinitializes to 1 โ†’ x++=2 โ†’ prints 2 2 2.


48.

Which storage class cannot have global scope?

A) static
B) register
C) extern
D) global

โœ… Answer: B
Explanation:
register can only be used locally inside a function.


49.

Output:

#include <stdio.h>
int x = 5;
void fun() {
    int x = 10;
    x += 2;
    printf("%d ", x);
}
int main() {
    fun();
    printf("%d", x);
}

A) 12 5
B) 12 12
C) 10 5
D) 10 12

โœ… Answer: A
Explanation:
Local x=10 โ†’ 10+2=12 โ†’ printed; global x=5 โ†’ printed in main โ†’ 12 5.


50.

Output:

#include <stdio.h>
static int x = 10;
int main() {
    static int y = 5;
    printf("%d %d", x, y);
}

A) 10 5
B) 0 5
C) 5 10
D) Compiler error

โœ… Answer: A
Explanation:
Both static variables initialized โ†’ printed 10 5.


51.

Which storage class is used to define variables accessible across multiple files?

A) static
B) auto
C) register
D) extern

โœ… Answer: D
Explanation:
extern references global variables defined elsewhere โ†’ allows cross-file access.


52.

Output:

#include <stdio.h>
void fun() {
    static int x = 0;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 0 1 2
B) 1 2 3
C) 0 0 0
D) 1 1 1

โœ… Answer: B
Explanation:
Static x=0 โ†’ increments each call โ†’ prints 1 2 3.


53.

Output:

#include <stdio.h>
void fun() {
    register int x = 0;
    x++;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 0 1 2
B) 1 2 3
C) 1 1 1
D) Compiler error

โœ… Answer: C
Explanation:
Register variable is local โ†’ reinitializes each call โ†’ prints 1 1 1.


54.

Which storage class cannot be initialized at declaration?

A) auto
B) static
C) register
D) extern

โœ… Answer: C
Explanation:
register variables cannot have an initializer because they are stored in CPU registers.


55.

Output:

#include <stdio.h>
int x = 3;
void fun() {
    extern int x;
    x += 2;
}
int main() {
    fun(); fun();
    printf("%d", x);
}

A) 3
B) 5
C) 7
D) Compiler error

โœ… Answer: C
Explanation:
Global x=3 โ†’ incremented by 2 twice โ†’ 3+2+2=7 โ†’ printed.


56.

Output:

#include <stdio.h>
void fun() {
    static int x = 1;
    x *= 2;
    printf("%d ", x);
}
int main() {
    fun(); fun(); fun();
}

A) 1 2 4
B) 2 4 8
C) 1 1 1
D) 2 2 2

โœ… Answer: B
Explanation:
Static x=1 โ†’ 12=2, 22=4, 4*2=8 โ†’ prints 2 4 8.


57.

Which storage class gives a variable default scope only inside a block?

A) extern
B) auto
C) static
D) register

โœ… Answer: B
Explanation:
auto variables have block scope and reinitialize each time.


58.

Output:

#include <stdio.h>
int main() {
    auto int x = 5;
    x += 3;
    printf("%d", x);
}

A) 5
B) 8
C) 0
D) Compiler error

โœ… Answer: B
Explanation:
auto x=5 โ†’ x+=3 โ†’ 8 โ†’ printed.


59.

Output:

#include <stdio.h>
extern int x;
int x = 50;
int main() {
    printf("%d", x);
}

A) 0
B) 50
C) Compiler error
D) Garbage

โœ… Answer: B
Explanation:
extern refers to global x=50 โ†’ printed.


60.

Output:

#include <stdio.h>
void fun() {
    static int x = 0;
    printf("%d ", x++);
}
int main() {
    fun(); fun(); fun();
}

A) 0 0 0
B) 0 1 2
C) 1 2 3
D) 1 1 1

โœ… Answer: B
Explanation:
Static x=0 โ†’ increments each call โ†’ prints 0 1 2.

About the Author

examhopeinfo@gmail.com

Administrator

Visit Website View All Posts

Post navigation

Previous: Recursion MCQs in C Language
Next: Arrays MCQs in C Language

Related News

India Squad for Afghanistan Series
  • IT

India Squad for Afghanistan Series Likely to Witness Major Changes, Leadership Reshuffle Possible

examhopeinfo@gmail.com May 19, 2026 0
Brazil Football Team
  • IT
  • Current Affairs
  • Sports News

Brazil Unveils 26-Man Squad for 2026 FIFA World Cup Under Carlo Ancelotti

examhopeinfo@gmail.com May 19, 2026 0
CSK Vs SRH Ipl match
  • IT
  • Current Affairs
  • Sports News

Ruturaj Gaikwad Highlights Squad Challenges After CSKโ€™s Defeat Hurts IPL 2026 Playoff Hopes

examhopeinfo@gmail.com May 19, 2026 0

Recent Posts

  • India Squad for Afghanistan Series Likely to Witness Major Changes, Leadership Reshuffle Possible
  • Brazil Unveils 26-Man Squad for 2026 FIFA World Cup Under Carlo Ancelotti
  • Ruturaj Gaikwad Highlights Squad Challenges After CSKโ€™s Defeat Hurts IPL 2026 Playoff Hopes
  • MS Dhoni Misses CSK Clash Against SRH Due to Fitness Concerns, Ruturaj Gaikwad Shares Update
  • IPL 2026 Playoff Race Heats Up: Rajasthan Royalsโ€™ Defeat to Delhi Capitals Changes Top-4 Battle

At ExamHope, we understand that preparing for exams can be challenging, overwhelming, and sometimes stressful. Thatโ€™s why we are dedicated to providing high-quality educational resources, tips, and guidance to help students and aspirants achieve their goals with confidence. Whether you are preparing for competitive exams, school tests, or professional certifications, ExamHope is here to make your learning journey smarter, easier, and more effective.

Quick links

  • About us
  • Contact Us
  • Privacy Policy
  • Terms and Conditions
  • Disclaimer
  • DMCA Policy

Category

  • Computer Network
  • Computer Organization and Architecture
  • Data Structures
  • C Language
  • Theory of Computation
  • Database

You may have missed

India Squad for Afghanistan Series
  • IT

India Squad for Afghanistan Series Likely to Witness Major Changes, Leadership Reshuffle Possible

examhopeinfo@gmail.com May 19, 2026 0
Brazil Football Team
  • IT
  • Current Affairs
  • Sports News

Brazil Unveils 26-Man Squad for 2026 FIFA World Cup Under Carlo Ancelotti

examhopeinfo@gmail.com May 19, 2026 0
CSK Vs SRH Ipl match
  • IT
  • Current Affairs
  • Sports News

Ruturaj Gaikwad Highlights Squad Challenges After CSKโ€™s Defeat Hurts IPL 2026 Playoff Hopes

examhopeinfo@gmail.com May 19, 2026 0
MS Dhoni News
  • IT
  • Current Affairs
  • Sports News

MS Dhoni Misses CSK Clash Against SRH Due to Fitness Concerns, Ruturaj Gaikwad Shares Update

examhopeinfo@gmail.com May 18, 2026 0
Copyright ยฉ All rights reserved for ExamHope. | MoreNews by AF themes.
Go to mobile version