0
0
Cprogramming~10 mins

Auto storage class - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an automatic variable inside the function.

C
void func() {
    [1] int x = 10;
}
Drag options to blanks, or click blank then click option'
Aauto
Bstatic
Cregister
Dextern
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'static' instead of 'auto' for local variables.
Confusing 'extern' with 'auto'.
2fill in blank
medium

Complete the code to declare a local variable with automatic storage class explicitly.

C
int main() {
    [1] int count = 5;
    return 0;
}
Drag options to blanks, or click blank then click option'
Aextern
Bauto
Cstatic
Dregister
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'static' which gives the variable static storage duration.
Using 'extern' which declares an external variable.
3fill in blank
hard

Fix the error in the code by choosing the correct storage class for the variable inside the function.

C
void example() {
    [1] int num = 100;
    printf("%d", num);
}
Drag options to blanks, or click blank then click option'
Aauto
Bextern
Cstatic
Dregister
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'extern' inside a function which is invalid.
Using 'static' changes the storage duration.
4fill in blank
hard

Fill both blanks to declare two automatic variables inside the function.

C
void test() {
    [1] int a = 1;
    [2] int b = 2;
}
Drag options to blanks, or click blank then click option'
Aauto
Bstatic
Dregister
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing 'auto' and 'static' for local variables.
Using 'register' unnecessarily.
5fill in blank
hard

Fill all three blanks to declare three automatic variables inside the function, where later variables depend on previous ones.

C
void func() {
    [1] int x = 5;
    [2] int y = x + 10;
    [3] int z = y * 2;
}
Drag options to blanks, or click blank then click option'
Aauto
Dstatic
Attempts:
3 left
💡 Hint
Common Mistakes
Declaring the first variable as static thinking it needs to persist, but all should be automatic.
Using static for all variables.