{"id":159,"date":"2020-04-03T09:20:41","date_gmt":"2020-04-03T09:20:41","guid":{"rendered":"https:\/\/temp.ashkerala.com\/?p=159"},"modified":"2020-04-03T09:20:41","modified_gmt":"2020-04-03T09:20:41","slug":"c-mcq-2","status":"publish","type":"post","link":"https:\/\/temp.ashkerala.com\/?p=159","title":{"rendered":"C++ MCQ -2"},"content":{"rendered":"<p>Question 1:<\/p>\n<p> The void specifier is used if a function does not have return type.<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0<br \/> Question 2:<\/p>\n<p> You must specify void in parameters if a function does not have any arguments.<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0<br \/> Question 3:<\/p>\n<p> Type specifier is optional when declaring a function<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0<br \/> Question 4:<\/p>\n<p> Study the following piece of code and choose the best answer<\/p>\n<p> int x=5, y=3, z;<\/p>\n<p> a=addition(x,y)<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The function addition is called by passing the values<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 The function addition is called by passing reference<\/p>\n<p> \u00a0<br \/> Question 5:<\/p>\n<p> In case of arguments passed by values when calling a function such as z=addidion(x,y),<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Any modifications to the variables x &amp; y from inside the function will not have any effect outside the function.<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 The variables x and y will be updated when any modification is done in the function<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The variables x and y are passed to the function addition<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 None of above are valid.<\/p>\n<p> \u00a0<br \/> Question 6:<\/p>\n<p> If the type specifier of parameters of a function is followed by an ampersand (&amp;Wink, that function call is<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 pass by value<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 pass by reference<\/p>\n<p> \u00a0<br \/> Question 7:<\/p>\n<p> In case of pass by reference<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The values of those variables are passed to the function so that it can manipulate them<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 The location of variable in memory is passed to the function so that it can use the same memory area for its processing<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 The function declaration should contain ampersand (&amp;Wink in its type declaration<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 All of above<\/p>\n<p> \u00a0<br \/> Question 8:<\/p>\n<p> Overloaded functions are<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Very long functions that can hardly run<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 One function containing another one or more functions inside it.<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Two or more functions with the same name but different number of parameters or type.<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 None of above<\/p>\n<p> \u00a0<br \/> Question 9:<\/p>\n<p> Functions can be declared with default values in parameters. We use default keyword to specify the value of such parameters.<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 False<\/p>\n<p> \u00a0<br \/> Question 10:<\/p>\n<p> Examine the following program and determine the output<\/p>\n<p> #include &lt;iostream&gt;<\/p>\n<p> using namespace std;<\/p>\n<p> int operate (int a, int b)<\/p>\n<p> {<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return (a * b);<\/p>\n<p> }<\/p>\n<p> float operate (float a, float b)<\/p>\n<p> {<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return (a\/b);<\/p>\n<p> }<\/p>\n<p> int main()<\/p>\n<p> {<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int x=5, y=2;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 float n=5.0, m=2.0;<\/p>\n<p> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cout &lt;&lt; operate(x,y) &lt;&lt;&#8220;\\t&#8221;;<\/p>\n<p> cout &lt;&lt; operate (n,m);<\/p>\n<p> return 0;<\/p>\n<p> }<\/p>\n<p> \u00a0<\/p>\n<p> a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 10.0\u00a0\u00a0\u00a0\u00a0\u00a0 5.0<\/p>\n<p> b.\u00a0\u00a0\u00a0\u00a0\u00a0 5.0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.5<\/p>\n<p> c.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 10.0\u00a0\u00a0\u00a0\u00a0\u00a0 5<\/p>\n<p> d.\u00a0\u00a0\u00a0\u00a0\u00a0 10\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.5<\/p>\n<p> Answers<\/p>\n<p> \u00a0<\/p>\n<p> 1.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a. True<\/p>\n<p> 2.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. False\u00a0 [ parameters can be empty without void too!]<\/p>\n<p> 3.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. False<\/p>\n<p> 4.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a. The function addition is called by passing the values<\/p>\n<p> 5.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a. Any modifications to the variables x &amp; y from inside the function will not have any effect outside the function<\/p>\n<p> 6.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. pass by reference<\/p>\n<p> 7.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. The location of variable in memory is passed to the function so that it can use the same memory area for its processing<\/p>\n<p> 8.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 d. None of above<\/p>\n<p> 9.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 b. False<\/p>\n<p> 10.\u00a0\u00a0\u00a0 d. 10\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.5<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question 1: The void specifier is used if a function does not have return type. a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True b.\u00a0\u00a0\u00a0\u00a0\u00a0 False \u00a0 Question 2: You must specify void in parameters if a function does not have any arguments. a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True b.\u00a0\u00a0\u00a0\u00a0\u00a0 False \u00a0 Question 3: Type specifier is optional when declaring a function a.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 True b.\u00a0\u00a0\u00a0\u00a0\u00a0 False&#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-159","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\/159","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=159"}],"version-history":[{"count":0,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=\/wp\/v2\/posts\/159\/revisions"}],"wp:attachment":[{"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/temp.ashkerala.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}