APSC160-sampleMidterm#1

APSC160-sampleMidterm#1 - Section 1: Short Answer Q1A....

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Section 1: Short Answer Q1A. Consider the following code segments: What Boolean expression can be inserted in place of *** in the code segment on the right so that these two code segments produce exactly the same output for every possible value of num1 and num2 ? Q1B. What value should be used in place of *** in the code segment below so that count has the value 20 when the code segment has executed? int count = 0; int indexA = 0; int indexB; while( indexA < *** ) { indexB = 0; while( indexB < 5 ) { count++; indexB++; } indexA++; } Q1D. Consider the following code segment: if( num1 < 2 || num2 > 7 ) printf( "A" ); if( num2 > 9 ) printf( "B" ); else printf( "C" ); What is printed on the screen when this code segment runs assuming that num1 and num2 are variables of type int and that num1 has the value 4 and num2 has the value 8? if( num1 > 9 ) { if( num2 < 12 ) printf( "A" ); } printf( "B" ); if( *** ) printf( "A" ); printf( "B" ); Page 2 of 4 Q1E. Consider the following code segment: int count = 1;...
View Full Document

Page1 / 4

APSC160-sampleMidterm#1 - Section 1: Short Answer Q1A....

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online