Sei sulla pagina 1di 12

FACULTY OF COMPUTER SCIENCE & ENGINEERING, GIK INSTITUTE

Please do not
Detached this
Sheet
CS101, Introduction to Computing and Programming
Fall 2015, Mid Term Examination
Total Marks = 40
Max. Time 60 minutes

Name:

______________________________

Reg. No: _____________________


Faculty: ______________________

CS101 - MCQs Answer Sheet


1. All the answers should be marked on this sheet
2. Please write down/encircle the letter for the best choice in the answer grid.
3. This sheet MUST NOT be detached from the question paper and should be
submitted back with the question paper.

MCQ#
1
2
3
4
5

a
a
a
a
a

b
b
b
b
b

c
c
c
c
c

Questions
MCQ#
d
21
d
22
d
23
d
24
d
25

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Sample

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b

c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c

d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Sample
1

a
a
a
a
a

b
b
b
b
b

c
c
c
c
c

d
d
d
d
d

a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a

b
b
b
b
b
b
b
b
b
b
b
b
b
b
b
b

c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c

d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d

CS101, Introduction to Computing and Programming


Fall 2015, Mid Term Examination
Total Marks = 40
Name: _______________________
Section: ___________________

Reg. no. ___________________

Note: Attempt all question.

Max. Time: 60 minutes

For the following problems, assume that preprocessor directives/header files have already
been included at the start of the program, and the given code is part of the main() function.
1. The .houses all essential chips and provides connecting circuitry
between them.
a) CPU
b)
Motherboard
c) Hard Drive
d)
Computer Casing
2. When a read-write head runs into a dust particle or other contaminant on the disk, it is
called as
a) Head Crash
b)
Head Damage
c) Jarring
d)
None of the above
3. Which of the following service is provided by Operating System?
a)
c)

Memory Management
Both (a) and (b)

b)
d)

File Management
None of the above

4. When a computer is powered on, BIOS first loads a very small program, placed in the
very first location of the hard-disk, into RAM and the processors starts running it. This is
called a program.
a)
c)

Bootstrap
Kernel

b)
d)

POSTs
Firmware

5. Which of the following order is correct in terms of decreasing speed?


a) Register, Cache, RAM, Hard Disk b)
Cache, RAM, Register, Hard Disk
c) Cache, Register, RAM, Hard Disk d)
Register, RAM, Cache, Hard Disk
6. What is the output of following C++ code?
int x=3,y=5;
if(x==3);
cout<<x<<endl;
else
cout<<y<<endl;

a)
c)

3
3 5

b)
d)

5
Syntax Error

7. What is the output of following C++ code?


int x=65;
char j=A;
if(x==y)
cout<<C++ is awsome<<endl;
else
cout<<C++ is headache<<endl;
a)

C++ is awesome

b)

c)

C++ is headache

d)

C++ is awesome
C++ is headache
No Output/Blank Screen

b)
d)

2
3

8. Write the output of following C++ code?


int x=3;
if(x==2);
x=0;
if(x==0)
x++;
else
x+=2;
cout>>x>>endl;
a)
c)

1
0

9. Write the output of following C++ code?


int i=5;
if (i++>=6) {
i=i+1;
cout<<i<<endl; }
else{
if(i>=6)
cout>>i>>endl;
else
cout>>no match of i<<endl; }
a)
c)

4
0

b)
d)

2
3

10. Write the output of following C++ code?


int i= 6;
if(i>5){
i++;
if( !(i>5) )
cout<<C++ is easy<<endl;
else;
cout<<C++ is too difficult<<endl;
}
else
cout<<C++ is Complex <<endl;
a) C++ is easy
C++ is too difficult
c) C++ is too difficult
C++ is complex

b)

C++ is easy

d)

C++ is too difficult

11. Write the output of following C++ code?


int i= 6;
if(i=i-i){
cout<<Hello World;
if( 1 )
cout<<Welcome World;
}
else
cout<<Thank you World <<endl;
cout<<Bye World;
a)
c)

Hello World
Welcome World
Thank you World
Bye World

b)

Hello World
Bye World
Welcome World
Bye World

d)

12. Write the output of following C++ code?


int x=3;
float y=3.0;
if(x==y)
cout<<x and y are equal<<endl;
else
cout<<x and y are not equal<<endl;
a) x and y are equal

b)

c) x and y are not equal

d)

x and y are equal


x and y are not equal
Syntax Error

13. What is the output of the following C/C++ code?


int x = 4 , y = 4 , z = 4;
z = ++x - y--;
cout<< x<<y<<z;
a) 530
b)
531
c) 532
d)
440
14. What is the output of the following C/C++ code?
int i = 4, j = 4, z;
int x , y;
x = ++i; y = --j;
z = x++ / y-- % 2 ;
cout << z;
a)
c)

1
2

b)
d)

0
3

15. What is the output of the following C/C++ code?


int a = 2 , b = 4;
double f1 = 2, f2 = 3;
cout<< f1*a + f2/b;
a)
c)

5.0
4

b)
d)

4.0
4.75

16. What is the output of the following C/C++ code?


int x = 3; int y = 4;
int a , b;
a = (x == 3) && (y <=4);
b = (x > 3) || (y != x);
cout<<a<<b<<endl;
a)
c)

00
10

b)
d)

01
11

17. What is the output of the following C/C++ code?


int s = 8, t = 8;
cout<< (s >= 8) << (t =< 8);
a)
c)

00
11

b)
d)

01
Syntax error

18. What is the output of the following C/C++ code?


int a = -3, b = 4, c , d;
c = !(a != b);
d = (a <= b) && (a = b);
cout<<c<<d;

a)
c)

00
10

b)
d)

01
11

19. What is the output of the following C/C++ code?


int x = 4, y = 10, z = 8;
cout<<float(y/x) + float(x)/z;
a)
c)

2.5
3.0

b)
d)

3
2.0

20. What is the output of the following C++ code?


for(int i = 50 ; i > 0; i -= 5)
cout << " " << i;
a)
b)
c)
d)

50 45 40 35 30 25 20 15 10 5
50 45 40 35 30 25 20 15 10 5 0
45 40 35 30 25 20 15 10 5 0
5 10 15 20 25 30 35 40 45 50

21. What is the output of the following C++ code?


int count, sum = 0;
for ( count = 1; count <= 6; count++ )
{
if ( count == 5 )
continue;
sum += count;
cout << "(" << count << " , " << sum << " , " << sum % 10 << "); ";
}
a)
b)
c)
d)

( 1 , 1 , 1 );
( 1 , 1 , 1 );
( 1 , 1 , 1 );
( 1 , 1 , 1 );

( 2 , 3 , 3 );
( 2 , 3 , 3 );
( 2 , 3 , 3 );
( 2 , 3 , 3 );

( 3 , 6 , 6 );
( 3 , 6 , 6 );
( 3 , 6 , 6 );
( 3 , 6 , 6 );

( 4 , 10 , 0 );
( 4 , 10 , 0 );
( 4 , 10 , 0 );
( 4 , 10 , 0 );

( 6 , 16 , 6 );
( 5 , 15 , 5 ); ( 6 , 16 , 6 );
( 5 , 15 , 5 );
( 5 , 15 , 5 ); ( 6 , 21 , 1 );

22. What is the output of the following C++ code?


for (int number = 1 ; number != 10 ; number + = 2 ) {
cout << number << " " ;
}
a)
c)

1 3 5 7 9
Logical error/Infinite loop

b)
d)

2 4 6 8 10
Syntax error

23. How many asterisks does the following code print?


int n = 1;
for ( int y = 0; y < 5 ; y++ , n++) {
cout << "\n";
for ( int x = 0; x < n; x++) {
cout << "*";
}
}
a)
c)

5
15

b)
d)

10
20

24. What is the output of the following C++ code?


int x, y;
for ( x = 0; x < = 3; x++) {
for (y = 0; y < = 2; y++)
x;
}
cout << x << " , " << y;
a)
c)

0,0
3,4

b)
d)

2,3
4,3

25. How many times does the following loop execute?


for (int i = 0 ; i < 10 ; i++)
cout << " " << i;
a)
c)

0
9

b)
d)

10
11

26. What is the output of the following C++ code?


for ( int i =1; i < 10; i++ ) {
int j = 5;
if (i % j)
continue;
cout << i << " ";
}
a)
c)

2 3 4 5
4 5

b)
d)

3 4 5
5

27. What is the output of the following C++ code?


int i=10;
switch(i%3)
{
case 10:
cout<<"10\n";
break;
case 0:
cout<<"0\n";
break;
case 1:
cout<<"1\n";
break;
default:
cout<<"Invalid";
}
a)
b)
c)
d)

10
1
0
Error

28. What is the output of the following C++ code?


int i=10;
for( ; i>1 ; i--)
int p=1;
switch(i)
{
case 10:
cout<<"10\n";
break;
case 0:
cout<<"0\n";
break;
case 1:
cout<<"1\n";
break;
default:
cout<<"Invalid";
}
a)
c)

Invalid
1

b)
d)

10
0

29. What is the output of the following C++ code?


float i=1.0;
switch(i)
{
case 0.0:
cout<<"0.0\n";
break;
case 1.0:
cout<<"1.0\n";
break;
default:
cout<<"Invalid";
}
a)
c)

0.0
Invalid

b)
d)

1.0
Syntax Error

30. What is the output of the following C++ code?


int n=10;
do
{
cout<<n<<", ";
--n;
if (n==3)
{
cout<<"countdown aborted!";
break;
}
if (n==5)
continue;
}
while(n>0);
a)
b)
c)
d)

10, 9, 8, 7, 6, 5, 4, 3, countdown aborted!


10, 9, 8, 7, 6, 4, 3, countdown aborted!
9, 8, 7, 6, 5, 4, countdown aborted!
9, 8, 7, 6, 4, countdown aborted!

31. What is the output of the following C++ code?


int a = 10, b=5;
do
{
cout << "value of a: " << a << endl;
a = a + b;
b++;
}while( a < 20 );

a)
c)

value of a: 20
value of a: 15

b)
d)

value of a: 10
value of a: 19

32. What is the output of the following C++ code?


int a = 0, counter=0;
do
{
a++;
int b=a+1;
do{
counter++;
cout<<counter;
b++;
} while (b<5);
}
while(a<3);
a)
c)

123456
654321

b)
d)

22222
011223

33. Which looping process (es) waits till the end of the loop to check the test condition?
(i) for
(ii) while
(iii) do-while
(iv) if-else
a)
c)

(i) only and (iv) only


(iii) only

b)
d)

(i) and (ii) only


None of the above combinations

34. What will be the output of the following if abs(i) gives the positive value of i.
(e.g. abs(-2) = 2)?
int n=3;
int i= -1*n;
do
{
int j=-1*n;
do{
if(abs(i)==abs(j))
cout<<"*";
else
cout<<" ";
j++;
}while (j<=n);
i++;
cout<<"\n";
}
while(i<=n);

10

a)

b)

c)

d)

35. What is the output of the following C/C++ code?


float s = 0.1;
while (s <= 0.5)
{
++s;
cout << s << endl;
}
a)
c)

0.1
0.1 0.2 0.3 0.4 0.5

b)
d)

1.1
1.5

36. What is the output of the following C++ code?


int x = 0;
while (x < 20)
{
while (x < 10)
{
if (x % 2 == 0)
{
cout << x << endl;
}
x++;
}
}
a)
c)

1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
02468

b)

0 2 4 6 8 10 12 14 16 18 20

d)

0 2 4 6 8 10

37. What is the output of the following C++ code?


int x=2,y=2;
while(x<=5 && y<=3)
cout<< ++x << ++y;
a)
c)

2323
2233

b)
d)

3344
3322

38. What is the output of the following C++ code?


int x=3,y=2;
while(x+y-1){
cout<< x-- + y;
}
11

a)
c)

5432
54321

b)
d)

531
12345

39. What is the output of the following C++ code?


int i = 0;
while (i++ != 0);
cout << i << endl;
a)
c)

-127 to +127
1

b)
d)

0 to 127
Infinite loop condition

40. What is the output of the following C++ code?


float i = 1.0, j = 0.05;
while (i < 2.0 && j <= 2.0) {
cout << i++ - ++j << endl;
}
a)
c)

0.05
-0.05

b)
d)

1.50
1.50

12

Potrebbero piacerti anche