A Introduction To Computing Questions For 2016 Exit Exam
A Introduction To Computing Questions For 2016 Exit Exam
3. Which of the following is the correct syntax of including a user defined header files in C++?
a) #include [userdefined] b) #include “userdefined”
c) #include <userdefined.h> d) #include <userdefined>
#include <iostream.h>
int main () {
}
A) syntax error B) No or empty output C) logical error D) A and C
8. What is the output of the following program
#include <iostream>
using namespace std;
int g = 20;
int main () {
int g = 10;
cout << g;
return 0;
}
A) syntax error B) 20 C) 10 D) 30
#include <iostream.h>
void func(void)
{
Cout<<"Hello";
}
int main()
{
func();
func(2);
}
#include <iostream>
using namespace std;
int main()
{
int p;
bool a = true;
bool b = false;
int x = 10;
int y = 5;
p = ((x | y) + (a + b));
cout << p;
return 0;
}
a) 12 b) 0 c) 2 d) 16
#include<iostream.h>
int main()
{
int i = 1;
int *ptr = &i;
cout <<* ptr;
return 0;
}
a) Runtime error may be possible c) 1
b) Compiler error may be possible d) 0
#include <iostream>
using namespace std;
int main( )
{
***** const char *a = "Hello\0World";
cout<<a;
return 0;
}
18. Which of the following is used to terminate the function declaration in C++?
a) ; b) ] c) ) d) :
#include <iostream>
using namespace std;
int main()
{
char c = 74;
cout << c;
return 0;
}
a) I b) J c) A d) N
if(x > y)
{
cout << "x is greater";
}
else
{
cout << "y is greater";
} }
A. x is greater B. y is greater C. Compiler error D. x is greater y is greater
21. Which of the following symbol is used to declare the preprocessor directives in C++?
a) $ b) ^ c) # d) *
22. What is Inheritance in C++?
a) Deriving new classes from existing classes
b) Overloading of classes
c) Classes with same names
d) Wrapping of data into a single class
23. What is meant by a polymorphism in C++?
a) class having only single form b) class having four forms
c) class having many forms d) class having two forms
24._______________loop will be executed at least once even if the condition is false initially
A.do-while B.while C.for D.none
25. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main ()
{
int a, b, c;
a = 2;
b = 7;
c = (a > b) ? a : b;
cout << c;
return 0;
}
a) 9 b) 14 c) 2 d) 7
a) \r b) \n c) \n\r d) \c
\r is used to represent carriage return which means move the cursor to the beginning of the next line.
a) \a b) \t c) \n d) \v
32. The value pi=3.14 can be represented using which data type?
a) double b) void c) int d) bool
- B) * C) % D) &
#include <iostream>
using namespace std;
int square (int *x, int *y)
{
*x = (*x) * --(*y);
}
int main ( )
{
int number = 3;
square(&number, &number);
cout << number;
return 0;
}
a) 3 b) Error c) 9 d) 6
1. extern int i;
2. int i;
a) both 1 and 2 declare i
b) 1 declares the variable i and 2 defines i
c) 1 declares and defines i, 2 declares i
d) 1 declares i,2 declares and defines i
#include <iostream>
using namespace std;
int main()
{
int i = 3;
char k='a';
cout << i+ k;
return 0;
}
A) 0 B) 3 C) 100 D) 68 E) Error
#include <iostream>
using namespace std;
int main()
{
void a = 10, b = 10;
int c = a + b;
cout << c;
return 0;
}
a) 20 b) logical error c) syntax error d) 40
string* x, y;
49. Which one of the following is not a possible state for a pointer.
a) hold the address of the specific object c) zero
b) point one past the end of an object d) point to a type
1. #include <iostream>
2. using namespace std;
3. int main()
4. {
5. int a = 5, b = 10, c = 15;
6. int *arr[ ] = {&a, &b, &c};
7. cout << arr[1];
8. return 0;
9. }
a) 5 b) 10 c) 15 d) it will return some hexa-decimal random number
1. #include <iostream>
2. using namespace std;
3. int main()
4. {
5. char *ptr;
6. char Str[] = "abcdefg";
7. ptr = Str;
8. ptr += 2;
9. cout << ptr;
10. return 0;
11. }
a) fg b) cdefg c) defg d) abcd e) abcdefg
#include <iostream>
using namespace std;
int main()
{
int const p = 5;
cout << ++p;
return 0;
}
a) 5 b) 6 c) Error d) 8
Prepared by: Mekuanint Erkie 2016 E.C
56. Which of the following statement is not true about preprocessor directives?
a) These are lines read and processed by the preprocessor
b) They do not produce any code by themselves
c) These must be written on their own line
d) They end with a semicolon
59. What is the only function all C++ programs must contain?
61. What punctuation is used to signal the beginning and end of code blocks?
62. which of the following operator can be used to calculate the value of one number raised to another.
A) ^ B) ** C) ^^ D) no operator
63. Which data type can be used to hold a wide character in C++?
65. Which of the following is the correct operator to compare two variables?
A) := B) = C) equal D) ==
A) 1 B) 0 C) Un evaluable D) None
a) a = a – 5 b) a = a / b c) a -= 5 d) a = a + 5
D) None of above
D) None of these
74. If there is more than one statement in the block of a for loop, which of the following must be
placed at the beginning and ending of the loop block?
76. which of the following statement allows us to make a decision from the number of choices?
a) for b) while c) switch d) go to
77. The destination statement for the goto label is identified by what label?
a) $ b) @ c) * d) :
78. More than one function had to access data ___ variables were used.
int main() {
int i ;
for (i = 0; i < 10; i++);
{
cout << i;
}
return 0;
}
a) 0123456789 b) 10 c) 012345678910 d) compile time error e) 0
a) from the innermost loop only. b) from the innermost switch only.
c) from all loops & switches. d) from the innermost loop or switch.
b) a-- is (a = a-1) POST DECREMENT operator and --a is (a = a-1) PRE DECREMENT operator
91. if you have to make decision based on multiple choices, which of the following is best suited?
#include <iostream>
using namespace std;
int main() {
if (0) {
cout << "Hello" ;
}
else
{
cout << "Good Bye" ;
}
return 0;
}
a) Hello b) Good Bye c) HelloGood bye d) Compilation Error
94. In situations where we need to execute body of the loop before testing the condition, we should
use_____.
97. The index number an array starts with __ and the last index number of an array of size n will be_
99. Which of the following accesses the seventh element stored in array?
#include <iostream>
using namespace std;
int main() {
int array[] = {0, 2, 4, 6, 7, 5, 3};
int n, result = 0;
for (n = 0; n < 7; n++){
result += array[n];
}
cout << result;
return 0;
}
a) 7 b) 21 c) 27 d) 3
#include <iostream>
using namespace std;
int main() {
char str[5] = "ABC";
cout << str [3];
cout << str;
return 0;
}
a) ABC b) ABCD c) AB d) AC
109. _______ is a collection of elements of similar data types in which each element is unique and located
in separate memory location.
A. pointer B. array C. attributes D. none
110. The data elements in the structure are also known as what?
a) objects b) members c) data d) objects & data
a) struct {int a;} b) struct a_struct {int a;} c) struct a_struct int a; d) struct a_struct {int a;};
#include <iostream>
#include <string.h>
using namespace std;
struct student{
int num;
char name[25];
};
int main() {
student stu;
stu.num = 123;
strcpy(stu.name, "john");
cout << stu.num <<"," ;
cout << stu.name << endl;
return 0;
}
a) 123,john b) john,john c) 123 d) runtime error
#include <iostream>
using namespace std;
int a=10;
int main(){
int a=20;
cout<<a<<”,”<<::a;
}
A) Syntax error B) 10, 20 C) 20,20 D) 20, 10 E) 10,10
A) B) C) D)
137. In a group of nested loops, which loop is executed the greatest number of times?
(A) The outermost loop. (B) The innermost loop.
(D) Cannot be determined without knowing the size of the loops bottom of form.
138. when you rectified all the syntax errors and the compiler produced an equivalent machine code of
your program but the result of program is not as desired. What type of error is happened?
a) syntax error b) logical error c) run time error d) compilation error
for(I;II;III)
{IV}
a) I b) II c) III d) IV
141. Which of the following is used to translate every single line command of high-level language code to
its equivalent machine language code?
a) Assembler b) compiler c) interpreter d) b and c
142. find the output of the following c++ code:
#include <iostream>
using namespace std;
int main() {
int x=(7%2-1)?-2:2;
cout<<x;
return 0;
}
a) 2 b) -2 c) un evaluable d) 0
146. which one completely takes you out of the program C++?
147. Which operator checks if the values of two operands are equal or not, if values are not equal then
condition becomes true?
153. the main module of a program contains the following sequence of statements call module A ___ call
module B ___ call module C ___ call module D ___ . Which of the following statement is executed after
call module B?
a) call module A b) call module C c) call module D d) first statement in module B
154. Which of the following statement is executed after all statements in call module B have been carried
out in above question 153?
a) call module A b) call module C c) call module D d) first statement in module C
155. An algorithm represented in the form of programming language is__________
a) flowchart b) pseudo code c) program d) none of the above
Prepared by: Mekuanint Erkie 2016 E.C
156. which of the following is a pictorial representation of an algorithm?
a) flowchart b) pseudo code c) program d) none of the above
157. which of the following symbol in a flowchart are used to indicate all arithmetic processes of adding,
multiplying, subtracting and dividing?
a) Rhombus b) Rectangle c) terminal d) parallelogram
158. After a programmer plans the logic of a program, she /he will next__________
a) understand the problem b) translate the program c) code the program d) test the program
159. Consider the following pseudo code and determine which structure is?
Get number, get another number, if the first number is greater than second number print the first number
Else print the second number.
a) Sequence b) loop c) decision d) nested
160. Consider the following pseudo code and determine which structure is?
Get number, get another number, multiply numbers and print the result.
a) Sequence b) loop c) decision d) nested
161. which of the following enhances the versatility of the computer to perform a set of instructions
repeatedly?
a) loop b) function c) header files d) statement
162. What is this operator called ?:
A. conditional B. relational C. casting operator D. unrelational
163. What is the difference between a flowchart and pseudocode?
a) Flowchart is diagrammatic whilst pseudo code is written in a programming language
b) flowchart is textual but pseudo code is diagrammatic
c) flowchart is a diagrammatic description of an algorithm whilst pseudo code is a textual description
of an algorithm
d) flowchart and pseudo code are the same thing
164. A flowchart needs to represent a situation where for each mark a MTU student is award
'Pass' or 'Fail' in exit exam...the system will consider the mark and if it's 50 or over award
'Pass', else it awards 'Fail'. This is an example of which of the algorithm constructs?
a) Decision b) Loop c) Sequence d) All of the above
165. When can algorithms be used?
a) Only with computers b) Only when programming
c) Only with flowcharts d) Any time to design solutions to problems
166. Which of the following is the smallest unit of data in a computer?
a) Bit b) KB c) Nibble d) Byte
Prepared by: Mekuanint Erkie 2016 E.C
167. Which of the following language does the computer understand?
a) Central Processing Unit b) Memory c) Arithmetic and Logic unit d) Control unit
b) Computer understands only binary language which is written in the form of 0s & 1s
c) Computer is a programmable electronic device that stores, retrieves, and processes the data
170. Which of the following unit is responsible for converting the data received from the user into a
computer understandable format?
a) Output Unit b) Input Unit c) Memory Unit d) Arithmetic & Logic Unit
174. Which of the following devices provides the communication between a computer and the outer
world
175. Which of the following is the device used for converting maps, pictures, and drawings into
digital form for storage in computers?
177. Which computer parts give you sound from the computer?
179. Which of the following programs enables you to calculate numbers related to rows and
columns?
182. A projector is an _ _ _ _ _ _ device that can take images generated by a computer and reproduce
them on a large, flat surface.
(a) input (b) output (c) input and output (d) monitor input
184. Christian has created a story of ten pages, but only wants to print the first two pages. Which
printer command should he choose?
int main () {
int x = 10;
x=x^2;
cout <<x;
}
A. 100 B. 12 C. 8 D. 20
int main () {
cout <<3/2;
}
A. 1.5 B. 1 C. Error D. 0
int main () {
cout <<3/2.0;
}
A. 1.5 B. 1 C. Error D. 0
int main () {
cout <<-3%2;
}
A. -1 B. 1 C. Error D. 0
if (!0 )
cout << “Hmmmm ”;
else
cout << “Ok”;
A. Hmmmm B. Ok C. Error D. Hmmmm OK
int main () {
while(10)
cout <<2;
return 0;
}
A. 2 B. 10 C. Error D. Display 2 infinitely
int main ()
{
for(int i=1;i<5;i++)
{
if (i%3==0)
exit(0);
cout<<i<<”,”;
}
cout<<”out”;
return 0;
}
A. 1,2,3,4,out B. 1,2,out C. 1,2,4,out D. 1,2
197. Which concept allows you to reuse the written code in C++?
199. Mouse is
a) pointing and drop device b) cursor-control device c) monitoring device d) a and b
200. Which input device is used for input text, numbers, and commands to the computer?