Engineering Online MCQ Number 0151 for assignment and exam purpose

Multiple choice question for engineering

Set 1

1. If we compile the sam.c file with the command “gcc -o sam sam.c”, then the executable file will be
a) a.out
b) sam
c) sam.out
d) None of the mentioned

Answer

Answer: b [Reason:] This is how the GCC is designed to take names of executable files.

2. What will be output of the following code?

#include<stdio.h>
int main(){
    printf("%dt",sizeof(6.5));
    printf("%dt",sizeof(90000));
    printf("%d",sizeof('A'));
    return 0;
}

a) 8 4 2
b) 8 4 2
c) 8 4 4
d) 8 4 3

Answer

Answer: c [Reason:] GCC compilers (32 bit compilers) size of:
double is 8 byte
long int is 8 byte
Character constant is 2 byte.

3. What will be output of the following c code? ( according to GCC compiler)

#include<stdio.h>
int main(){
    signed x;
    unsigned y;
    x = 10 +- 10u + 10u +- 10;
    y = x;
    if(x==y)
         printf("%d %d",x,y);
    else if(x!=y)
         printf("%u  %u",x,y);
    return 0;
}

a) 0 0
b) 65536 -10
c) 0 65536
d) Compilation error

Answer

Answer: a [Reason:] Consider on the expression:
x = 10 +- 10u + 10u +- 10;
10: It is signed integer constant.
10u: It is unsigned integer constant.
X: It is signed integer variable.
As we know operators enjoy higher precedence than binary operators. So
x = 10 + (-10u) + 10u + (-10);
= 10 + -10 + 10 + (-10);
= 0
So, Corresponding signed value of unsigned 10u is +10.

4. What will be output of the following c code?

#include<stdio.h>
int main(){
    const int *p;
    int a=10;
    p=&a;
    printf("%d",*p);
    return 0;
}

a) 0
b) 10
c) Garbage Value
d) Any Memory address

Answer

Answer: b [Reason:] In the following declaration
const int *p;
p can keep address of constant integer.

5. What will be output of the following c code?

#include<stdio.h>
int main(){
    int a= sizeof(signed) +sizeof(unsigned);
    int b=sizeof(const)+sizeof(volatile);
    printf("%d",a+++b);
    return 0;
}

a) 10
b) 9
c) 8
d) Error

Answer

Answer: c [Reason:] Default data type of signed, unsigned, const and volatile is intSo, a = 4 and b =4
Now, a+++b
= a++ + b
= 4 + 4 //due to post increment operator.
=8
But in Linux gcc compiler size of int is 4 byte so your out will be 16.

6. Which of the following is integral data type?
a) void
b) char
c) float
d) double

Answer

Answer: b [Reason:] In c char is integral data type. It stores the ASCII value.

7. What will be output of the following c code?

#include<stdio.h>
int main(){
    volatile int a=11;
    printf("%d",a);
    return 0;
}

a) 11
b) Garbage
c) -2
d) Cannot Predict

Answer

Answer: d [Reason:] Value of volatile variable can’t be predicted because its value can be changed by any microprocessor interrupt

8. What will be output of the following c code?

#include<stdio.h>
const enum Alpha{
      X,
      Y=5,
      Z
}p=10;
int main(){
    enum Alpha a,b;
    a= X;
    b= Z;
    printf("%d",a+b-p); 
    return 0; 
}

a) -4
b) -5
c) 10
d) 11

Answer

Answer: a [Reason:] Default value X is zero and
Z = Y + 1 = 5 + 1 = 6
So, a + b – p
=0 + 6 -10 = -4.

Set 2

1. If a state does not know whether it will make a shift operation or reduction for a terminal is called
a) Shift/reduce conflict
b) Reduce /shift conflict
c) Shift conflict
d) Reduce conflict

Answer

Answer: a [Reason:] As the name suggests that the conflict is between shift and reduce hence it is called shift reduce conflict.

2. When there is a reduce/reduce conflict?
a) If a state does not know whether it will make a shift operation using the production rule i or j for a terminal
b) If a state does not know whether it will make a shift or reduction operation using the production rule i or j for a terminal
c) If a state does not know whether it will make a reduction operation using the production rule i or j for a terminal
d) None of the mentioned

Answer

Answer: c [Reason:] It occurs when If a state does not know whether it will make a reduction operation using the production rule i or j for a terminal.

3. When ß ( in the LR(1) item A -> ß.a,a ) is not empty, the look-head
a) Will be affecting
b) Does not have any affect
c) Shift will take place
d) Reduction will take place

Answer

Answer: b [Reason:] There is no terminal before the non terminal beta.

4. When ß is empty (A -> ß.,a ), the reduction by A-> a is done
a) If next symbol is a terminal
b) Only If the next input symbol is a
c) Only If the next input symbol is A
d) Only if the next input symbol is a

Answer

Answer: d [Reason:] The next token is considered in this case it’s a.

5. The construction of the canonical collection of the sets of LR (1) items are similar to the construction of the canonical collection of the sets of LR (0) items. Which is an exception?
a) Closure and goto operations work a little bit different
b) Closure and goto operations work similarly
c) Closure and additive operations work a little bit different
d) Closure and associatively operations work a little bit different.

Answer

Answer: a [Reason:] Closure and goto do work differently in case of LR (0) and LR (1).

6. Terminal table
a) Contains all constants in the program
b) Is a permanent table of decision rules in the form of patterns for matching with the uniform symbol table to discover syntactic structure
c) Consist of a full or partial list of the token is as they appear in the program created by lexical analysis and used for syntax analysis and interpretation
d) Is a permanent table which lists all keywords and special symbols of the language in symbolic form

Answer

Answer: d [Reason:] A permanent database that has entry for each terminal symbols such as arithmetic operators, keywords, punctuation characters such as ‘;’, ‘,’etc Fields: Name of the symbol.

7. Advantage of incorporating the macro-processor into pass 1 is that
a) Many functions have to be implemented twice
b) Functions are combined not necessarily creating intermediate files as output from the macro-processor and input to the assembler
c) More flexibility is provided to the programmer in that he may use all the features of the assembler in conjunction with macros
d) All of the mentioned

Answer

Answer: d [Reason:] A general-purpose macro processor or general purpose pre-processor is a macro …designed primarily for string manipulation, macro definition.

8. Which of the following is a phase of a compilation process?
a) Lexical Analysis
b) Code Generation
c) Both of the mentioned
d) None of the mentioned

Answer

Answer: c [Reason:] Lexical analysis and code generation is a phase of compilation process.

9. System program such a s compiler are designed so that they are
a) Re-enterable
b) Non reusable
c) Serially usable
d) None of the mentioned

Answer

Answer: a [Reason:] Re-enterable is the keyword for compiler being designed.

10. A series of statements explaining how the data is to be processed is called
a) Assembly
b) Machine
c) COBOL
d) Program

Answer

Answer: d [Reason:] A program is a sequence of instructions, written to perform a task by computer. It requires programs to function, typically executing the program’s instructions in a central processor.

11. A loader is a program that
a) Program that places functions into memory and prepares them for execution.
b) Program that automates the translation of assembly language into machine language.
c) Program accepting another program written in a high level language and produces as object program
d) None of the mentioned

Answer

Answer: a [Reason:] A loader is the part of an operating system that is responsible for loading programs and libraries. It is important in the process of placing the programs into memory and executing them.

12. A system program that setup an executable program in main memory ready for execution is
a) Assembler
b) Linker
c) Loader
d) Load and go

Answer

Answer: c [Reason:] A loader is the part of an operating system that is responsible for loading programs and libraries. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution.

Set 3

1. Which of the following is a phase of a compilation process?
a) Lexical Analysis
b) Code Generation
c) Lexical Analysis & Code Generation
d) None of the mentioned

Answer

Answer: c [Reason:] Lexical analysis and code generation is a phase of compilation process.

2. System program such a s compiler are designed so that they are
a) Re-enterable
b) Non reusable
c) Serially usable
d) None of the mentioned

Answer

Answer: a [Reason:] Re-enterable is the keyword for compiler being designed.

3. A series of statements explaining how the data is to be processed is called
a) Assembly
b) Machine
c) COBOL
d) Program

Answer

Answer: d [Reason:] A program is a sequence of instructions, written to perform a task by computer. It requires programs to function, typically executing the program’s instructions in a central processor.

4. A loader is a program that
a) Program that places functions into memory and prepares them for execution.
b) Program that automates the translation of assembly language into machine language.
c) Program accepting another program written in a high level language and produces as object program
d) None of the mentioned

Answer

Answer: a [Reason:] A loader is the part of an operating system that is responsible for loading programs and libraries. It is important in the process of placing the programs into memory and executing them.

5. A system program that setup an executable program in main memory ready for execution is
a) Assembler
b) Linker
c) Loader
d) Load and go

Answer

Answer: c [Reason:] A loader is the part of an operating system that is responsible for loading programs and libraries. It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution.

6. Which of the following system program forgoes the production of object code to generate absolute machine code and load it into the physical main storage location from which it will be executed immediately upon completion of the assembly?
a) Two pass assembler
b) Load and go assembler
c) Macro processor
d) Linker

Answer

Answer: b [Reason:] Each pass scans the program, the first pass generates the symbol table and the second pass generates the machine code.

7. Uniform symbol table
a) Has all constants in the program
b) Permanent table of rules in the form of patterns for matching with the uniform symbol table to discover syntactic structure
c) Consists of full or partial list of the tokens as they appear in the program created by Lexical analysis and used for syntax analysis and interpretation
d) A permanent table which has all key words and special symbols of the language in symbolic form

Answer

Answer: c [Reason:] Each pass scans the program, the first pass generates the symbol table and the second pass generates the machine code.

8. Assembler is a program that
a) Puts programs into memory and executes them
b) Translates the assembly language into machine language
c) Writes in high level language and produces an object program
d) None of the mentioned

Answer

Answer: b [Reason:] An assembler is a program that takes basic computer instructions and converts them into a pattern of bits that the computer’s processor can use to perform its basic operations.

Set 4

1. Can Left Linear grammar be converted to Right Linear grammar
a) Yes
b) No

Answer

Answer: a [Reason:] Since right-linear grammars are regular, it follows that left-linear grammars are also regular.

2. CFG is
a) Compiler
b) A language expression
c) Regular Expression
d) None of the mentioned

Answer

Answer: b [Reason:] They are defined by rule A->b where A is non terminal and b is terminal.

3. The idea of an automation with a stack as auxiliary storage
a) Finite automata
b) Push Down Automata
c) Deterministic Automata
d) None of the mentioned

Answer

Answer: b [Reason:] Push Down Automata manipulate the Stack as a part of performing a transition.

4. Transition of finite automata is
a) Finite Diagram
b) State Diagram
c) Node Diagram
d) E-R Diagram

Answer

Answer: b [Reason:] Transition of finite automata is Finite Diagram.

5. A context free language is called ambiguous if
a) It has 2 or more than 2 left derivations for some terminal string ѡ є L (G)
b) It has 2 or more than 2 left derivations for some terminal string ѡ є L (G)
c) Both of the mentioned
d) None of the mentioned

Answer

Answer: c [Reason:] When two or more Left and right most derivative occur the grammar turn ambiguous .

6. Which of the following statement is true?
a) Every language that is defined by regular expression can also be defined by finite automata
b) Every language defined by finite automata can also be defined by regular expression
c) We can convert regular expressions into finite automata
d) All of the mentioned

Answer

Answer: d [Reason:] All these statements are true w.r.t regular expression.

7. Which of the following identity is wrong?
a) R + R = R
b) (R*)* = R*
c) ƐR = Rɛ = R
d) ØR = RØ = RR*

Answer

Answer: d [Reason:] Regular grammar combined with empty does not give R* instead gives empty.

8. Grammars that can be translated to DFAs :
a) Left linear grammar
b) Right linear grammar
c) Generic grammar
d) All of the mentioned

Answer

Answer: b [Reason:] Right Linear grammar can be translate to DFA.

9. A language is regular if and only if it is accepted by finite automata
a) The given statement statement is true
b) Given statement is false
c) Statement is partially true
d) None of the mentioned

Answer

Answer: a [Reason:] Regular Language is accepted by Finite Automata. Every regular language is Context free.

10. A Push Down Automata is if there is at most one transition applicable to each configuration?
a) Deterministic
b) Non deterministic
c) Finite
d) Non finite

Answer

Answer: a [Reason:] In every situation only one transition is available as continuation then the result is deterministic push down automata.

Set 5

1. Consider the languages L1 = and L2 = {a}. Which one of the following represents L1 L2* U L1*
a) €
b) a*
c) All of the mentioned
d) None of the mentioned

Answer

Answer: a [Reason:] L1* = * which is { }.

2. Choose the correct statement for the following
compilers-questions-answers-minimization-dfa-1-q2
a) For the language accepted by A which is also a minimal DFA
b) A accepts all strings over {0,1} of length at least 2
c) All of the mentioned
d) None of the mentioned

Answer

Answer: c [Reason:] The DFA can be minimized to two states and the second state is final state .We reach second state after a 0.

3. Given the language L = {ab, aa, baa}, which of the following strings are in L*?
1) abaabaaabaa
2) aaaabaaaa
3) baaaaabaaaab
4) baaaaabaa
a) 1, 2, 3
b) 2, 3, 4
c) 1, 2, 4
d) 1, 3, 4

Answer

Answer: c [Reason:] The given alphabet ∑ contains only one symbol {a} and the given NFA accepts all strings with any number of occurrences of ‘a’.

4. W hat is the complement of the language accepted by the NFA shown below?
compilers-questions-answers-minimization-dfa-1-q4
a) A,B
b) B
c) C
d) D,C

Answer

Answer: b [Reason:] The given alphabet contains only one symbol {a} and the given NFA accepts all strings with any number of occurrences of ‘a’.

5. A deterministic finite automation (DFA)D with alphabet {a,b} is given below Which of the following finite state machines is a valid minimal DFA which accepts the same language as D?
compilers-questions-answers-minimization-dfa-1-q5
a) compilers-questions-answers-minimization-dfa-1-q5a
b) compilers-questions-answers-minimization-dfa-1-q5b
c) compilers-questions-answers-minimization-dfa-1-q5c
d) compilers-questions-answers-minimization-dfa-1-q5d

Answer

Answer: a [Reason:] Options (B) and (C) are invalid because they both accept ‘b’ as a string which is not accepted by give DFA. D is invalid because it accepts bb+a which are not accepted by given DFA.

6.Let w be any string of length n is {0,1}*. Let L be the set of all substring of w.
State the minimum number of states in a NDFA that accepts L?
compilers-questions-answers-minimization-dfa-1-q6
a) n-1
b) n
c) n +1
d) 2n-1

Answer

Answer: c [Reason:] We need minimum n+ 1 state to build NFA that accepts all substrings of a binary string. Following NFA accepts all strings containing substring of “010″ and it has 4 states.

7. Which one of the following languages over the alphabet {0,1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)*?
a) String with substring 00
b) string with at most two 0’s
c) string containg at least two 0’s
d) None of the mentioned

Answer

Answer: c [Reason:] The regular expression has two 0′s surrounded by (0+1)* which means accepted strings must have at least 2 0′s.

8. Which one of the following is FALSE?
a) Every NFA can be converted to DFA
b) Every subset of a recursively enumerable set is recursive
c) All of the mentioned
d) None of the mentioned

Answer

Answer: b [Reason:] Every subset of a recursively enumerable set is recursive.

9. Match the following NFAs with the regular expressions they correspond to
1. ϵ + 0(01*1 + 00) * 01*
2. ϵ + 0(10 *1 + 00) * 0
3. ϵ + 0(10 *1 + 10) *1
4. ϵ + 0(10 *1 + 10) *10 *
compilers-questions-answers-minimization-dfa-1-q9
a) P-2,Q-1,R-3,S-4
b) P-1, Q-3, R-2,S-4
c) P-1,,Q-2,R-3,S-4
d) P-3.Q-2,R-1,S-4

Answer

Answer: c [Reason:] The above figures correctly represent the figures
Eg: p gives ϵ + 0(01*1 + 00) * 01* and the q gives the expression ϵ + 0(10 *1 + 00) * 0 and so on.

10. Which of the following are regular sets?
I. { an b2m | n>=0, m>=0}
II. {an bm |n=2m}
III. {an bm | n!= m}
IV {xcy |x,y€{a,b)*}
a) I and IV
b) I and III
c) I and only
d) IV

Answer

Answer: a [Reason:] We can write DFA for both I and IV.

Total Views: 19

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.