Sie sind auf Seite 1von 12

FACULTY OF COMPUTER SCIENCE & ENGINEERING, GIK INSTITUTE

Please do not
Detached this
Sheet
Solution Mid Term Fall 2015
Name: ______________________________
CS101, Introduction to Computing and Programming
Fall 2015, Mid Term Examination Reg. No: _____________________
Total Marks = 40 Max. Time 60 minutes
FCSE
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.

Questions
MCQ# MCQ#
1 a b c d 21 a b c d
2 a b c d 22 a b c d
3 a b c d 23 a b c d
4 a b c d 24 a b c d
5 a b c d 25 a b c d
6 a b c d 26 a b c d
7 a b c d 27 a b c d
8 a b c d 28 a b c d
9 a b c d 29 a b c d
10 a b c d 30 a b c d
11 a b c d 31 a b c d
12 a b c d 32 a b c d
13 a b c d 33 a b c d
14 a b c d 34 a b c d
15 a b c d 35 a b c d
16 a b c d 36 a b c d
17 a b c d 37 a b c d
18 a b c d 38 a b c d
19 a b c d 39 a b c d
20 a b c d 40 a b c d
Sample a b c d Sample a b c d

1
CS101, Introduction to Computing and Programming
Fall 2015, Mid Term Examination
Total Marks = 40

Name: _______________________ Reg. no. ___________________


Section: ___________________

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) Memory Management b) File Management


c) Both (a) and (b) d) 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) Bootstrap b) POSTs
c) Kernel d) 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;

2
a) 3 b) 5
c) 3 5 d) 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++ is awesome


C++ is headache
c) C++ is headache d) No Output/Blank Screen

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) 1 b) 2
c) 0 d) 3

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) 4 b) 2
c) 0 d) 3

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 b) C++ is easy


C++ is too difficult
c) C++ is too difficult d) C++ is too difficult
C++ is complex

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) Hello World b) Hello World


Welcome World Bye World
c) Thank you World d) Welcome World
Bye World Bye World

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) x and y are equal


x and y are not equal
c) x and y are not equal d) Syntax Error

4
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) 1 b) 0
c) 2 d) 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) 5.0 b) 4.0
c) 4 d) 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) 00 b) 01
c) 10 d) 11

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


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

a) 00 b) 01
c) 11 d) 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;

5
a) 00 b) 01
c) 10 d) 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) 2.5 b) 3
c) 3.0 d) 2.0

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


for(int i = 50 ; i > 0; i -= 5)
cout << " " << i;

a) 50 45 40 35 30 25 20 15 10 5
b) 50 45 40 35 30 25 20 15 10 5 0
c) 45 40 35 30 25 20 15 10 5 0
d) 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) ( 1 , 1 , 1 ); ( 2 , 3 , 3 ); ( 3 , 6 , 6 ); ( 4 , 10 , 0 ); ( 6 , 16 , 6 );
b) ( 1 , 1 , 1 ); ( 2 , 3 , 3 ); ( 3 , 6 , 6 ); ( 4 , 10 , 0 ); ( 5 , 15 , 5 ); ( 6 , 16 , 6 );
c) ( 1 , 1 , 1 ); ( 2 , 3 , 3 ); ( 3 , 6 , 6 ); ( 4 , 10 , 0 ); ( 5 , 15 , 5 );
d) ( 1 , 1 , 1 ); ( 2 , 3 , 3 ); ( 3 , 6 , 6 ); ( 4 , 10 , 0 ); ( 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) 1 3 5 7 9 b) 2 4 6 8 10
c) Logical error/Infinite loop d) Syntax error

6
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) 5 b) 10
c) 15 d) 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) 0,0 b) 2,3
c) 3,4 d) 4,3

25. How many times does the following loop execute?


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

a) 0 b) 10
c) 9 d) 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) 2 3 4 5 b) 3 4 5
c) 4 5 d) 5

7
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) 10
b) 1
c) 0
d) 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) Invalid b) 10
c) 1 d) 0

8
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) 0.0 b) 1.0
c) Invalid d) 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) 10, 9, 8, 7, 6, 5, 4, 3, countdown aborted!


b) 10, 9, 8, 7, 6, 4, 3, countdown aborted!
c) 9, 8, 7, 6, 5, 4, countdown aborted!
d) 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 );

9
a) value of a: 20 b) value of a: 10
c) value of a: 15 d) 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) 123456 b) 22222
c) 654321 d) 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) (i) only and (iv) only b) (i) and (ii) only


c) (iii) only d) 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) 0.1 b) 1.1
c) 0.1 0.2 0.3 0.4 0.5 d) 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) 1 2 3 4 5 6 7 8 9 10 b) 0 2 4 6 8 10 12 14 16 18 20
11 12 13 14 15 16 17 18 19 20
c) 02468 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) 2323 b) 3344
c) 2233 d) 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) 5432 b) 531
c) 54321 d) 12345

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


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

a) -127 to +127 b) 0 to 127


c) 1 d) 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) 0.05 b) 1.50
c) -0.05 d) 1.50

12

Das könnte Ihnen auch gefallen