0% found this document useful (0 votes)
45 views2 pages

Choose The Best Answer: Programming II Homework 2 COMP012 Group 1003fall 2013 Due Sunday, 22 November

This document contains a programming homework assignment for a Programming II class. It includes 10 multiple choice questions about C++ loops and conditional statements. It also includes a short programming question asking the student to write a for loop that prints their first name for the first 3 iterations and last name for the last 3 iterations. The homework is due on Sunday, November 22nd, 2013 and is for COMP012 Group 1003 in the Fall 2013 semester.

Uploaded by

Alti Adel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

Choose The Best Answer: Programming II Homework 2 COMP012 Group 1003fall 2013 Due Sunday, 22 November

This document contains a programming homework assignment for a Programming II class. It includes 10 multiple choice questions about C++ loops and conditional statements. It also includes a short programming question asking the student to write a for loop that prints their first name for the first 3 iterations and last name for the last 3 iterations. The homework is due on Sunday, November 22nd, 2013 and is for COMP012 Group 1003 in the Fall 2013 semester.

Uploaded by

Alti Adel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming II Homework 2

COMP012 Group 1003Fall 2013


Due Sunday, 22 November

Choose the best answer


1. What is the final value of x when the code int x;
7.What is the output?for(int i=1; i<15; i=i+3) { cout<< I ; }
for(x=0; x<10; x++) {} is run?
A. 10 A.15
B. 9
C. 0 B.1471013
D. 1
C.47101316
2. When does the code block following
D.147101516
while(x<100) execute?
A. When x is less than one hundred
B. When x is greater than one hundred
8.What is the output of the following:
C. When x is equal to one hundred
int Output=10;
D. While it wishes
boolean b1 = false;
if((b1==true) && ((Output+=10)==20)) // false && false
3. Which is not a loop structure? {
A. for cout<<"Hello ";
B. do while }
C. while else
{
D. repeat until
cout<<"Khaled ";
}
4. How many times is a do while loop guaranteed
to loop?
A. 0
9. Pick the for loop which duplicates this while loop:
B. Infinitely
C. 1 int x = 0 ;
D. Variable while ( x < 50)
{
5.Which looping process checks the test condition cout<<x;
at the end of the loop x=x+5;
a] for }
b] while[
a. for ( int x = 5; x <= 500; x+=5 ) {cout<<x;}
c] do-while[ b. for ( int x = 0; x < 50; x+=5 ) {cout<<x;}
d] no looping process checks the test condition [ c. for ( float x = 0.0; x < 500.0; x += 5.0 ) {cout<<x;}
at the end d. for ( int x = 500; x >= 0; x-=5 ) {cout<<x;}

6. If there is more than one statement in the block . 10 : In C++, the condition ( 4 > y > 1 ):
of a for loop, which of the following must be placed a. Evaluates correctly and could be replaced by
at the beginning and the ending of the loop block ( 4 > y && y > 1 ).

b. Does not evaluate correctly and should be replaced by


a] parentheses ) (
( 4 > y && y > 1 ).
b] braces } {
c] brackets ] [ c. Evaluates correctly and could not be replaced by
d] arrows > < ( 4 > y && y > 1 ).

d. Does not evaluate correctly and should not be replaced by


( 4 > y && y > 1 ).

Page 1
Programming II Homework 2
COMP012 Group 1003Fall 2013
Due Sunday, 22 November

Q3) write a program that use for statements to print your first name and last name

.Use Iteration statement of counter 6-

.Print your first name at first 3 loops and you last at the last 3 loops -

int main()
{

for(int i=1; i<=6 ; i++)


{
if (i <= 3)
cout<<"Khaled";
else
cout<<"Alanhami";
}

return 0;
}

Page 2

You might also like