0% found this document useful (0 votes)
84 views6 pages

C++ Chapter 6 MCQs

It is the file containing important mcqs of c++

Uploaded by

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

C++ Chapter 6 MCQs

It is the file containing important mcqs of c++

Uploaded by

Zainab Batool
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
Choice Questions 1. Which of the following is used to repeat the execution of specific block of statements? a. Decision statement ybeLoop structure ¢. switch d. if..else captor 6 > Oneeeuton a ep stmt oo Deraion fen ‘4. hich of the following loop i available in C++ 7 oe ne Taos whe cm 4g sthe simplest loop in C+ anges wat ‘a.do.while for ile ieee 4 tron trates aways exes a eat nee 7 vee bor whe coer . Nhe conditon comes efor he body ofthe oop? aa tao. whe cer avoue «Tle op conn ser ao ae Be whie ce bane «temas win cy as nap rknon ; Tite Header center (ee sabes nneneneor eae srs wContint contol Terminator Guess sn apne! ones op ote xy? : oak ‘terminate cet d.stop sa Atm within afoop ical Meee oop eames oop €Infiteloep 4. Dual oop slop which never ende scaled it op Running oop eEeins 10 {4 Nested oop stand sip some tates iad up ane efile cwitch sip 1 ner of expresions in forl9p ae M fe) <2 as a rr—sess———C assignment Validation ‘Ciatrement/decrement Recalling 1. Which pr ofthe for oop is executed only once? ‘a. Condition . Validation pAfnitialization 4. All 1m Whe op isthe bestiftheurer need to eter exaly 20 values? a wile ta do..whle ete dLininite 19, The semicolon is placed at the end of condition in: Aion ‘bas. hileloop——forloop all £2, Which of thefellowing i loop statement? a hire et oop structure tha ss the lop con : t-test loop ». Prequalified | : uaifed Yop S chee +d. Pretest loop eho ve_pe fo : erm be Notest Prequalified a esrtest 2, whieh sequence the while loop is Awhile loop is more appropt aay erates vot Koss In alvance le enews oer only a Teast ne cuted Te the Cotte lop sho Aothe loop should be exe i of boty initialization, testing a. Bee 1 Todine ntiatzation extn of bay station ttig veut of by “Llitiatization, execution of body, testing fo use than a for Joop when: 1. The body ofthe Toop is to be executed atleast once fhe terminate contin occurs unexpectedly ‘. The program executes at Teast once €. The number of iterations are known in advance nahh situation a do...while loop is more appropriate to use? (hen the body of the loop isto be executed at least once 'b. When the loop terminates unexpectedly ‘c. When the program executes at least once 4. When the number of iterations is known in advance In which situation a for loop is more appropriate to use? ‘a. When the body of the loop is to be executed atleast once b, When the loop terminates unexpectedly . When the program executes at least once _d. When the numberof iterations is known in advance ‘A loop exit condition must: ‘abe the last instruction inthe body of the loop b.evaluate to true or false «be the first instruction in the body of the loop <. not use compound conditions ‘What is missing in the following code with respect to the loop? int loopCount while (loopCount <= 5) ' cout Hi’ loopCourit++; Ve (fie initialization of the loop control variable ‘i. The testing ofthe loop control variable ‘The incrementing of the loop control variable dd, Nothing is missing. ‘What isthe output of the following code? intn=4; dof , ‘yea <= 1 108 b.110 107 aw Chapter 6 => Looping Structures a. What isthe output ofthe following code? int 8: Forfint 1: |< n'3; 49) 2, What ithe output ofthe following code? a int forfnt ev i>" Ori) we bs Seti the output ofthe following code? intn= 5 while (<2) 14 (8%2) se neneds b.20 nat is the output ofthe following code? intxe Ly =o while <= 9) i yoyt? xexth 1 A copy 10 bat ‘ina is the output ofthe fotlowing code? intn=0; for(t m= 0;m <10;m+*) coat cen 4) break: oo ao Ippon i ee oop 40, Whatisihe valu of variables after the following 10°? ints=0; intn=0, ao ( if >= 4) continwe: J while (<9) i oa oe 4s. Wnatisthe valu of after execution ofthe following code segment? inta=2; intb=0; while <3) ' oy babel; 1 ae acast a6 os «66 42 What isthe value ofa after execution ofthe following code? inta=25; for Gite = arat3; 20 aB 604 65 43. Ifn = 3, what will be the value of n after execiting the following code? do nt 2, while (n-< 48); * b. 32 Kas 4.9% ‘th, How many times will the following loop display "Hello"? for =0:1-< 20:54) ‘coute<"Hello; ‘lion ae as 4g, how many tne wil he flloeog Toop esplay “sort for 20 0:i-) rl oa wat ei as Wat isthe value of pater executing the following code? “ wer eco) me << sa any tins wi te following ie oy pn Rl" while(i<= 10) itech! a0 bs - se init numberof ines ciate output of given ode fragment? melee wesetion et te ba ei at nas 1b 2c ab | 4 4 oe 6 a Bo ee aa Boa a. 15. b 16. _¢ 17. 18. 19. b 2. d 2a 2a Boa 24. Bb 26. a 7d 2B. b 29. a =| 30. a aa i 358 367 b x 38.0 39.8 10. a1._b 2b Ma 45. a 46. 47d 48. c

You might also like