{"id":160,"date":"2020-04-03T09:21:09","date_gmt":"2020-04-03T09:21:09","guid":{"rendered":"https:\/\/temp.ashkerala.com\/?p=160"},"modified":"2020-04-03T09:21:09","modified_gmt":"2020-04-03T09:21:09","slug":"c-mcq-3","status":"publish","type":"post","link":"https:\/\/temp.ashkerala.com\/?p=160","title":{"rendered":"C++ MCQ -3"},"content":{"rendered":"<p>Question 1:<\/p>\n<p> Find out the error in following block of code.<\/p>\n<p> If (x = 100)<\/p>\n<p> \u00a0\u00a0\u00a0 Cout &lt;&lt; \u0393\u00c7\u00a3x is 100\u0393\u00c7\u00a5;<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 100 should be enclosed in quotations<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 There is no semicolon at the end of first line<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Equals to operator mistake<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 Variable x should not be inside quotation<\/p>\n<p> \u00a0<br \/> Question 2:<\/p>\n<p> Looping in a program means<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Jumping to the specified branch of program<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 Repeat the specified lines of code<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Both of above<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 None of above<\/p>\n<p> \u00a0<br \/> Question 3:<\/p>\n<p> The difference between while structure and do structure for looping is<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 In while statement the condition is tested at the end of first iteration<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 In do structure the condition is tested at the beginning of first iteration<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The do structure decides whether to start the loop code or not whereas while statement decides whether to repeat the code or not<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 In while structure condition is tested before executing statements inside loop whereas in do structure condition is tested before repeating the statements inside loop<\/p>\n<p> \u00a0<br \/> Question 4:<\/p>\n<p> Which of the following is not a looping statement in C?<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 while<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 until<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 do<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 for<br \/> Question 5:<\/p>\n<p> Which of the following is not a jump statement in C++?<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 goto<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 switch<\/p>\n<p> \u00a0<br \/> Question 6:<\/p>\n<p> Which of the following is selection statement in C++?<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 goto<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 exit<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 switch<\/p>\n<p> \u00a0<br \/> Question 7:<\/p>\n<p> The continue statement<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 resumes the program if it is hanged<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 resumes the program if it was break was applied<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 skips the rest of the loop in current iteration<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 all of above<\/p>\n<p> \u00a0<br \/> Question 8:<\/p>\n<p> Consider the following two pieces of codes and choose the best answer<br \/> Code 1:<\/p>\n<p> switch (x) {<\/p>\n<p> case\u00a0 1:<\/p>\n<p> cout &lt;&lt;\u0393\u00c7\u00a5x is 1\u0393\u00c7\u00a5;<\/p>\n<p> break;<\/p>\n<p> case 2:<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cout &lt;&lt;\u0393\u00c7\u00a5x is 2\u0393\u00c7\u00a5;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break;<\/p>\n<p> default:<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cout &lt;&lt;\u0393\u00c7\u00a5value of x unknown\u0393\u00c7\u00a5;<\/p>\n<p> }<\/p>\n<p> \u00a0<br \/> Code 2<\/p>\n<p> If (x==1){<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Cout &lt;&lt;\u0393\u00c7\u00a5x is 1\u0393\u00c7\u00a5;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> Else if (x==2){<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Cout &lt;&lt; \u0393\u00c7\u00a3x is 2\u0393\u00c7\u00a5;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> Else{<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Cout &lt;&lt;\u0393\u00c7\u00a5value of x unknown\u0393\u00c7\u00a5;<\/p>\n<p> }\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0<\/p>\n<p> \u00a0<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Both of the above code fragments have the same behaviour<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 Both of the above code fragments produce different effects<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The first code produces more results than second<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 The second code produces more results than first.<\/p>\n<p> \u00a0<br \/> Question 9:<\/p>\n<p> Observe the following block of code and determine what happens when x=2?<\/p>\n<p> switch (x){<\/p>\n<p> case 1:<\/p>\n<p> case 2:<\/p>\n<p> case 3:<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cout&lt;&lt; &#8220;x is 3, so jumping to third branch&#8221;;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 goto thirdBranch;<\/p>\n<p> default:<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cout&lt;&lt;&#8220;x is not within the range, so need to say Thank You!&#8221;;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p> \u00a0<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Program jumps to the end of switch statement since there is nothing to do for x=2<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 The code inside default will run since there is no task for x=2, so, default task is run<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Will display x is 3, so jumping to third branch and jumps to thirdBranch.<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 None of above<\/p>\n<p> \u00a0<br \/> Question 10<\/p>\n<p> Which of the following is false for switch statement in C++?<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 It uses labels instead of blocks<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 we need to put break statement at the end of the group of statement of a condition<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 we can put range for case such as case 1..3<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 None of above<\/p>\n<p> Answers<\/p>\n<p> \u00a0<\/p>\n<p> 1.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c. Equals to operator mistake<\/p>\n<p> 2.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. Repeat the specified lines of code<\/p>\n<p> 3.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 In while structure condition is tested before executing statements inside loop whereas in do structure condition is tested before repeating the statements inside loop<\/p>\n<p> 4.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. Until<\/p>\n<p> 5.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d. Switch<\/p>\n<p> 6.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d. Switch<\/p>\n<p> 7.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c. skips the rest of the loop in current iteration<\/p>\n<p> 8.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a. Both of the above code fragments have the same behaviour<\/p>\n<p> 9.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 c. Will display x is 3, so jumping to third branch and jumps to thirdBranch<\/p>\n<p> 10.\u00a0\u00a0 c. we can put range for case such as case 1..3<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question 1: Find out the error in following block of code. If (x = 100) \u00a0\u00a0\u00a0 Cout &lt;&lt; \u0393\u00c7\u00a3x is 100\u0393\u00c7\u00a5; a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 100 should be enclosed in quotations b.\u00a0\u00a0\u00a0\u00a0\u00a0 There is no semicolon at the end of first line c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Equals to operator mistake d.\u00a0\u00a0\u00a0\u00a0\u00a0 Variable x should not be inside quotation \u00a0 Question 2:&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[15],"tags":[],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-c-and-c-programming-language"],"_links":{"self":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=160"}],"version-history":[{"count":0,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts\/160\/revisions"}],"wp:attachment":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}