CMPT 128 Study Guide - Midterm Guide: Scantron Corporation, Memory Address, Null Character

221 views9 pages
1
!
Simon Fraser University
Computing Science 128
Midterm 2 Quiz – D200
Time: 45 minutes
Instructor: Ghassan Hamarneh / Liaqat Ali
This examination has 10 pages inclusive.
Verify that you have a complete paper.
ü Read each question carefully before answering it.
ü Answer all questions on the scantron sheet
ü Each question is worth 1 mark
ü There are 35 problems; It is possible to earn 35/34
ü You have 45 minutes to complete the quiz
ü NO CALCULATORS ALLOWED
Good luck!
Total
/ 34
! !
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 9 pages and 3 million more documents.

Already have an account? Log in
2
1. What!is!the!output!of!the!given!code!snippet?!
!
int$intArray[5][5]$=${{12,7,3},{4,6,3,6},{8,1,4,2},{23,11,8}};$
cout$<<$intArray[3][2]$<<$",$";$
cout$<<$intArray[2][3];$
!
A) 8,!1!
B) 2,!8!!
C) 8,!2!
D) 11,!!3!
!
2. What!is!printed!by!the!following!code!snippet?!
!
double$*Xptr$=$NULL;$
double$id$=$38;$
Xptr$=$&id;$
id$/=$2;$
cout$<<$*Xptr;$
$
A) NULL!
B) The!address!of!variable!id!
C) 19!
D) 38!
!
3. What!is!the!value!of!*Yptr!after!the!following!lines!of!code!are!executed?!
! !
double$*Yptr$=$NULL;$
double$Y[12]$=${$1,$2,$3,$4,$5,$6,$7};$
Yptr$=$&Y[5+1];$
!
A) 6!
B) 7!
C) 8!
D) 9!
!
4. Which!one!of!the!following!statements!is!an!invalid!initialization!of!an!array?!
!
A) int!myArr1[5]!=!{!0,!1,!2};!
B) int!myArr2[!]!!=!{!0,!1,!2};!
C) int!myArr3[5]!=!{!0,!1,!2,!3,!4,!5};!
D) All!of!the!above!statements!are!invalid.!
!
! !
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 9 pages and 3 million more documents.

Already have an account? Log in
3
5. What!is!the!problem!with!the!C++!code!snippet!below?!
!
double$cost($double$price,$int$reps$);$
int$main()$
{$$$
$int$k$=$0;$ $
$ cout$<<$cost(10.5,$4)$<<$endl;$$$$
$return$0;$$
}$
$
double$cost(double$price,$int$reps)$
{$
$$$ $for$(int$k$=$0;$;$k++)$$
$$$ ${$ price*=3;$}$
$$$ $return$price;$
}$
!
A) The!function!cost!is!called!with!the!wrong!type!of!parameters.!
B) The!function!cost!has!a!syntax!error.!
C) The!function!cost!is!incorrectly!used!in!the!cout!statement.!
D) The!function!cost!has!a!logical!error.!!
!
6. A!function!__________!contains!the!statements!that!make!up!the!function.!!
!
A) prototype!
B) definition!
C) call!
D) parameter!list!
!
7. What!is!the!valid!range!of!index!values!for!an!array!of!size!20?!
!
A) 0!to!20!
B) 0!to!19!
C) 1!to!20!
D) 1!to!19!
!
8. What!will!be!output!of!the!following!code!snippet?!
!
int$$a=4,$$b=4,$$c=10;$
c$=$a==b;$
printf("%d",c);$
return$0;$
$
A) 0!
B) 1!
C) 4!
D) 10!
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 9 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents