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

Vivo X200 Price Drop
  • IT
  • Current Affairs
  • Tech News

Vivo X200: जाने कितनी कम कीमत पर मिल रहा ये 9400 मिडिया टेक प्रोसेसर वाला स्मार्टफोन

examhopeinfo@gmail.com December 23, 2025 0
Samsung Galaxy S25 Plus
  • IT
  • Current Affairs
  • Tech News

Samsung Galaxy S25 Plus पर मिल रही भारी छूट ,जाने सेल प्राइस

examhopeinfo@gmail.com December 22, 2025 0
Electricity bill saving Smart Plug
  • IT
  • Current Affairs
  • Tech News

AI के इस ज़माने में कैसे बिजली बचा रहे हैं यह स्मार्ट प्लग?

examhopeinfo@gmail.com December 21, 2025 0

Recent Posts

  • Vivo X200: जाने कितनी कम कीमत पर मिल रहा ये 9400 मिडिया टेक प्रोसेसर वाला स्मार्टफोन
  • Samsung Galaxy S25 Plus पर मिल रही भारी छूट ,जाने सेल प्राइस
  • AI के इस ज़माने में कैसे बिजली बचा रहे हैं यह स्मार्ट प्लग?
  • क्या है यह GhostPairing Scam और बिना पासवर्ड और सिम के क्यों हो रहा है व्हाट्सप्प अकाउंट हैक
  • Leica कैमरे के साथ जल्द लॉन्च हो सकता है Xiaomi Ultra 17

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

Vivo X200 Price Drop
  • IT
  • Current Affairs
  • Tech News

Vivo X200: जाने कितनी कम कीमत पर मिल रहा ये 9400 मिडिया टेक प्रोसेसर वाला स्मार्टफोन

examhopeinfo@gmail.com December 23, 2025 0
Samsung Galaxy S25 Plus
  • IT
  • Current Affairs
  • Tech News

Samsung Galaxy S25 Plus पर मिल रही भारी छूट ,जाने सेल प्राइस

examhopeinfo@gmail.com December 22, 2025 0
Electricity bill saving Smart Plug
  • IT
  • Current Affairs
  • Tech News

AI के इस ज़माने में कैसे बिजली बचा रहे हैं यह स्मार्ट प्लग?

examhopeinfo@gmail.com December 21, 2025 0
Ghost Pairing Scam on Whatsapp
  • IT
  • Current Affairs
  • Tech News

क्या है यह GhostPairing Scam और बिना पासवर्ड और सिम के क्यों हो रहा है व्हाट्सप्प अकाउंट हैक

examhopeinfo@gmail.com December 21, 2025 0
Copyright © All rights reserved for ExamHope. | MoreNews by AF themes.