Consider the following C++ code fragment: int x = 20, p = 1, n; while (x >= 5){ n = 5; while (n = 5; x = x - 3) for(n = 5 ; n= 5; n = 5) for (x = x - 3;n=5; x = x - 3) for(n ++; n= 5 ;x = x - 3) for(n...


Consider the following C++ code fragment:<br>int x = 20, p = 1, n;<br>while (x >= 5){<br>n = 5;<br>while (n <= x){<br>p += n;<br>n++;<br>}<br>x = x - 3;<br>}<br>Which of the following C++ code fragments is equivalent to the above code?<br>2. int x, p = 1, n;<br>for(x = 20; x>= 5; x = x - 3)<br>for(n = 5 ; n<<= x;n ++)<br>p+= n;<br>1. int x, p = 1, n;<br>for (x = 20 ; x >= 5; n = 5)<br>for (x = x - 3;n<= x ;n++ )<br>p += n;<br>3. int x, p = 1, n;<br>for(x = 20; x >=5; x = x - 3)<br>for(n ++; n<= x; n= 5)<br>p += n;<br>4. int x, p = 1, n;<br>for(x = 20; x>= 5 ;x = x - 3)<br>for(n = 5 ; n<= x ; p+= n )<br>n ++;<br>a. code 1<br>b. code 3<br>C. code 4<br>d. code 2<br>

Extracted text: Consider the following C++ code fragment: int x = 20, p = 1, n; while (x >= 5){ n = 5; while (n <= x){="" p="" +="n;" n++;="" }="" x="x" -="" 3;="" }="" which="" of="" the="" following="" c++="" code="" fragments="" is="" equivalent="" to="" the="" above="" code?="" 2.="" int="" x,="" p="1," n;="" for(x="20;" x="">= 5; x = x - 3) for(n = 5 ; n<= x;n="" ++)="" p+="n;" 1.="" int="" x,="" p="1," n;="" for="" (x="20" ;="" x="">= 5; n = 5) for (x = x - 3;n<= x="" ;n++="" )="" p="" +="n;" 3.="" int="" x,="" p="1," n;="" for(x="20;" x="">=5; x = x - 3) for(n ++; n<= x;="" n="5)" p="" +="n;" 4.="" int="" x,="" p="1," n;="" for(x="20;" x="">= 5 ;x = x - 3) for(n = 5 ; n<= x="" ;="" p+="n" )="" n="" ++;="" a.="" code="" 1="" b.="" code="" 3="" c.="" code="" 4="" d.="" code="">

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here