Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you have the following pseudo code: 01 k = (j + 13)/27 02 loop: 03 if k

ID: 3800330 • Letter: S

Question

Suppose you have the following pseudo code: 01 k = (j + 13)/27 02 loop: 03 if k > 10 then goto out 04 k = k + 1 05 i = 3 * k - 1 06 goto loop 07 out: 08 if ((k==l) || (k==2)) j = 2 * k - 1 09 if ((k==3) || (k==5)) j = 3 * k + 1 10 if (k==4) j = 4 * k -1 Rewrite the code between lines 01-07 as a proper loop in the following languages: a) C++ b) Python c) Ruby (you will need to investigate how to do this on your own) Rewrite the code between lines 08-10 using a multiple-selector statement in the following languages a) C++ b) Python c) Ruby (you will need to investigate how to do this on your own)

Explanation / Answer

#include <iostream>
using namespace std;
int main(){
   int i,j,k;
   k=(j+13)/27;
   while(k<10){
       k=k+1;
       i=3*k-1;
   }
   if((k==1)||(k==2))
   j=2*k-1;
   if((k==1)||(k==2))
   j=3*k+1;
   if(k==4)
   j=4*k-1;
return 0
}

*******************This is python program********************

j=0
k=(j+13)/27
while k > 10:
k=k+1
i=3*k-1

if((k==1)or(k==2)):
j=2*k-1
if((k==1)or(k==2)):
j=3*k+1
if(k==4):
j=4*k-1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote