C Storage Classes and Type QualifiersLast Updated : 09 Sep, 2021ReadDiscussCoursesC Storage Classes and Type QualifiersPlease wait while the activity loads.If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled.If loading fails, click here to try againQuestion 1Which of the following is not a storage class specifier in C? auto register static extern volatile C Storage Classes and Type Qualifiers 50 C Language MCQs with Answers Discuss itQuestion 1-Explanation: volatile is not a storage class specifier. volatile and const are type qualifiers.Question 2Output of following program? #include <stdio.h> int main() { static int i=5; if(--i){ main(); printf("%d ",i); } return 0; } 4 3 2 11 2 3 40 0 0 0Compiler ErrorC Storage Classes and Type Qualifiers Discuss itQuestion 2-Explanation: A static variable is shared among all calls of a function. All calls to main() in the given program share the same i. i becomes 0 before the printf() statement in all calls to main().Question 3 #include <stdio.h> int main() { static int i=5; if (--i){ printf("%d ",i); main(); } } 4 3 2 11 2 3 44 4 4 40 0 0 0C Storage Classes and Type Qualifiers Discuss itQuestion 3-Explanation: Since i is static variable, it is shared among all calls to main(). So is reduced by 1 by every function call.Question 4 #include <stdio.h> int main() { int x = 5; int * const ptr = &x; ++(*ptr); printf("%d", x); return 0; } Compiler ErrorRuntime Error65C Storage Classes and Type Qualifiers Discuss itQuestion 4-Explanation: See following declarations to know the difference between constant pointer and a pointer to a constant. int * const ptr —> ptr is constant pointer. You can change the value at the location pointed by pointer p, but you can not change p to point to other location. int const * ptr —> ptr is a pointer to a constant. You can change ptr to point other variable. But you cannot change the value pointed by ptr. Therefore above program works well because we have a constant pointer and we are not changing ptr to point to any other location. We are only incrementing value pointed by ptr.Question 5 #include <stdio.h> int main() { int x = 5; int const * ptr = &x; ++(*ptr); printf("%d", x); return 0; } Compiler ErrorRuntime Error65C Storage Classes and Type Qualifiers Discuss itQuestion 5-Explanation: See following declarations to know the difference between constant pointer and a pointer to a constant. int * const ptr —> ptr is constant pointer. You can change the value at the location pointed by pointer p, but you can not change p to point to other location. int const * ptr —> ptr is a pointer to a constant. You can change ptr to point other variable. But you cannot change the value pointed by ptr. In the above program, ptr is a pointer to a constant. So the value pointed cannot be changed.Question 6 #include<stdio.h> int main() { typedef static int *i; int j; i a = &j; printf("%d", *a); return 0; } Runtime Error0Garbage ValueCompiler ErrorC Storage Classes and Type Qualifiers Discuss itQuestion 6-Explanation: Compiler Error -> Multiple Storage classes for a. In C, typedef is considered as a storage class. The Error message may be different on different compilers.Question 7Output? #include<stdio.h> int main() { typedef int i; i a = 0; printf("%d", a); return 0; } Compiler ErrorRuntime Error01C Storage Classes and Type Qualifiers Discuss itQuestion 7-Explanation: There is no problem with the program. It simply creates a user defined type i and creates a variable a of type i.Question 8 #include<stdio.h> int main() { typedef int *i; int j = 10; i *a = &j; printf("%d", **a); return 0; } Compiler ErrorGarbage Value100C Storage Classes and Type Qualifiers Discuss itQuestion 8-Explanation: Compiler Error -> Initialization with incompatible pointer type. The line typedef int *i makes i as type int *. So, the declaration of a means a is pointer to a pointer. The Error message may be different on different compilers.Question 9Output? #include <stdio.h> int fun() { static int num = 16; return num--; } int main() { for(fun(); fun(); fun()) printf("%d ", fun()); return 0; } Infinite loop13 10 7 4 114 11 8 5 215 12 8 5 2C Storage Classes and Type Qualifiers Discuss itQuestion 9-Explanation: Since num is static in fun(), the old value of num is preserved for subsequent functions calls. Also, since the statement return num– is postfix, it returns the old value of num, and updates the value for next function call. fun() called first time: num = 16 // for loop initialization done; In test condition, compiler checks for non zero value fun() called again : num = 15 printf("%d \n", fun());:num=14 ->printed Increment/decrement condition check fun(); called again : num = 13 ---------------- fun() called second time: num: 13 In test condition,compiler checks for non zero value fun() called again : num = 12 printf("%d \n", fun());:num=11 ->printed fun(); called again : num = 10 -------- fun() called second time : num = 10 In test condition,compiler checks for non zero value fun() called again : num = 9 printf("%d \n", fun());:num=8 ->printed fun(); called again : num = 7 -------------------------------- fun() called second time: num = 7 In test condition,compiler checks for non zero value fun() called again : num = 6 printf("%d \n", fun());:num=5 ->printed fun(); called again : num = 4 ----------- fun() called second time: num: 4 In test condition,compiler checks for non zero value fun() called again : num = 3 printf("%d \n", fun());:num=2 ->printed fun(); called again : num = 1 ---------- fun() called second time: num: 1 In test condition,compiler checks for non zero value fun() called again : num = 0 => STOP Question 10 #include <stdio.h> int main() { int x = 10; static int y = x; if(x == y) printf("Equal"); else if(x > y) printf("Greater"); else printf("Less"); return 0; } Compiler ErrorEqualGreaterLessC Storage Classes and Type Qualifiers Discuss itQuestion 10-Explanation: In C, static variables can only be initialized using constant literals. This is allowed in C++ though. See this GFact for details. 1234 There are 31 questions to complete.You have completedquestionsquestionYour accuracy isCorrectWrongPartial-CreditYou have not finished your quiz. If you leave this page, your progress will be lost.Correct AnswerYou SelectedNot AttemptedFinal Score on QuizAttempted Questions CorrectAttempted Questions WrongQuestions Not AttemptedTotal Questions on QuizQuestion DetailsResultsDateScoreHintTime allowedminutessecondsTime usedAnswer Choice(s) SelectedQuestion Text Need more practice!Keep trying!Not bad!Good work!Perfect!