CS101 Midterm Fall 2015 - Solution PDF
CS101 Midterm Fall 2015 - Solution PDF
CS101 Midterm Fall 2015 - Solution PDF
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
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.
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
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
if(x==3);
cout<<x<<endl;
else
cout<<y<<endl;
2
a) 3 b) 5
c) 3 5 d) Syntax Error
a) 1 b) 2
c) 0 d) 3
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;
if( 1 )
cout<<”Welcome World”;
}
else
cout<<”Thank you World” <<endl;
cout<<”Bye World”;
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
a) 1 b) 0
c) 2 d) 3
a) 5.0 b) 4.0
c) 4 d) 4.75
a) 00 b) 01
c) 10 d) 11
a) 00 b) 01
c) 11 d) Syntax error
5
a) 00 b) 01
c) 10 d) 11
a) 2.5 b) 3
c) 3.0 d) 2.0
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
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 );
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
a) 0,0 b) 2,3
c) 3,4 d) 4,3
a) 0 b) 10
c) 9 d) 11
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
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
9
a) value of a: 20 b) value of a: 10
c) value of a: 15 d) value of a: 19
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
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)
a) 0.1 b) 1.1
c) 0.1 0.2 0.3 0.4 0.5 d) 1.5
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
a) 2323 b) 3344
c) 2233 d) 3322
11
a) 5432 b) 531
c) 54321 d) 12345
a) 0.05 b) 1.50
c) -0.05 d) 1.50
12