C MiscLast Updated : 01 Sep, 2021ReadDiscussCoursesC MiscPlease 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 1In the C language (GATE CS 2002)At most one activation record exists between the current activation record and the activation record for the mainThe number of activation records between the current activation record and the activation record for the main depends on the actual function calling sequence.The visibility of global variables depends on the actual function calling sequence.Recursion requires the activation record for the recursive function to be saved on a different stack before the recursive function can be called.C Misc Discuss itQuestion 1-Explanation: a) –> There is no such restriction in C language b) –> True c) –> False. In C, variables are statically scoped, not dynamically. c) –> False. The activation records are stored on the same stack.Question 2The C language is. (GATE CS 2002)A context free languageA context sensitive languageA regular languageParsable fully only by a Turing machineC Misc Discuss itQuestion 2-Explanation: C and C++ are context-sensitive languages. There are several reasons:To parse C and C++, you start by using a very powerful preprocessor. These preprocessors are inevitably written by hand (they are not based on a theoretic foundation like regular expressions or context-free grammars).The grammar is ambiguous: it has LR conflicts, such as the if-then-else conflict. Parsers typically resolve this using context (an “else” matches the closest “if”).C and C++ lexers require lexical feedback to differentiate between typedef names and identifiers. That is, the context-sensitive lexer needs help from the “context-free” parser to distinguish between an identifier “foo” and a typedef name “foo”. In this snippet,int foo; typedef int foo; foo x;the first “foo” is an identifier while the second and third are typedef names. You need to parse typedef declarations to figure this out (and since types have nested parentheses, this is definitely at least as hard as parsing a context-free language). This means that the parser and lexer are mutually recursive, so it doesn’t make sense to say that the parser is context free while the lexer is context sensitive.Ref: C and C++ are not context freeQuestion 3The number of tokens in the following C statement isprintf("HELLO WORLD");3598C Misc Lexical analysis Discuss itQuestion 3-Explanation: In a C source program, the basic element recognized by the compiler is the “token.” A token is source-program text that the compiler does not break down into component elements. There are 6 types of C tokens : identifiers, keywords, constants, operators, string literals and other separators. There are total 5 tokens in the above printf statement. Below are tokens in above program.printf ( "HELLO WORLD" ) ;Question 4Which of the following best describes C languageC is a low level languageC is a high level language with features that support low level programmingC is a high level languageC is a very high level languageC Misc Discuss itQuestion 4-Explanation: See http://geeksquiz.com/c-language-set-1-introduction/Question 5Assume that the size of an integer is 4 bytes. Predict the output? C #include <stdio.h> int fun() { puts(" Hello "); return 10; } int main() { printf("%d", sizeof(fun())); return 0; } 4Hello 44 HelloCompiler ErrorC Misc Discuss itQuestion 6 #include <stdio.h> int main() { int a[][3] = {1, 2, 3, 4, 5, 6}; int (*ptr)[3] = a; printf("%d %d ", (*ptr)[1], (*ptr)[2]); ++ptr; printf("%d %dn", (*ptr)[1], (*ptr)[2]); return 0; } 2 3 5 62 3 4 54 5 0 0none of the aboveC Misc Discuss itQuestion 7Consider line number 3 of the following C- program. C int main ( ) { /* Line 1 */ int I, N; /* Line 2 */ fro (I = 0, I < N, I++); /* Line 3 */ } Identify the compiler's response about this line while creating the object-moduleNo compilation errorOnly a lexical errorOnly syntactic errorsBoth lexical and syntactic errorsGATE-CS-2005 C Misc Discuss itQuestion 7-Explanation: Lexical errors refer to errors related to the lexemes or tokens in the program, such as misspelled keywords or identifiers that are not recognized by the language. Here, "fro" instead of "for".Syntactic errors occur when the code violates the grammar or syntax rules of the programming language. Here, inside for loop there is coma instead of semicolomnQuestion 8Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2, the reference will be resolved atEdit-timeCompile-timeLink-timeLoad-timeGATE-CS-2004 C Misc Discuss itQuestion 8-Explanation: Note: Static linking is done at link-time, dynamic linking or shared libraries are brought in only at runtime. (A) Edit-time : Function references can never be given/determined at edit-time or code-writing time. Function references are different from function names. Function names are used at edit-time and function references are determined at linker-time for static libraries or at runtime for dynamic libraries. (B) Compile-time : Compile time binding is done for functions present in the same file or module. (C) Link-time : Link time binding is done in the linker stage, where functions present in separate files or modules are referenced in the executable. (D) Load-time : Function referencing is not done at load-time. Hence, correct answer would be (C). This solution is contributed by Vineet Purswani.Question 9Assume the following C variable declaration C int *A [10], B [10][10]; Of the following expressionsI. A [2] II. A [2][3] III. B [1] IV. B [2][3] which will not give compile-time errors if used as left hand sides of assignment statements in a C program ?I, II and IV onlyII, III and IV onlyII and IV onlyIV onlyC Misc Discuss itQuestion 9-Explanation: A is an array of pointers to int, and B is a 2-D array.A[2]= can take a pointerA[2][3]= can take an intB[1]=B[1] is the base address of the array and it cannot be changed as array in C is a constant pointer.B[2][3]= can take an integerSo, option (A) is the answer.Question 10The C language is:A context free languageA context sensitive languageA regular languageParsable fully only by a Turing machineGATE-CS-2002 C Misc Discuss itQuestion 10-Explanation: C and C++ are context-sensitive languages. There are several reasons:To parse C and C++, you start by using a very powerful preprocessor. These preprocessors are inevitably written by hand (they are not based on a theoretic foundation like regular expressions or context-free grammars).The grammar is ambiguous: it has LR conflicts, such as the if-then-else conflict. Parsers typically resolve this using context (an “else” matches the closest “if”).C and C++ lexers require lexical feedback to differentiate between typedef names and identifiers. That is, the context-sensitive lexer needs help from the “context-free” parser to distinguish between an identifier “foo” and a typedef name “foo”. In this snippet,int foo; typedef int foo; foo x;the first “foo” is an identifier while the second and third are typedef names. You need to parse typedef declarations to figure this out (and since types have nested parentheses, this is definitely at least as hard as parsing a context-free language). This means that the parser and lexer are mutually recursive, so it doesn’t make sense to say that the parser is context free while the lexer is context sensitive.Ref: C and C++ are not context free 123 There are 25 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!