In: Computer Science
What is the exact output of the following pseudocode segment?
METHOD MAIN
CALL myMethod (0,2)
CALL myMethod (3,5)
CALL myMethod (6,7)
END MAIN
| 
 Answer:  | 
METHOD myMethod(A,B)
BEGIN
    WHILE (A < B)
         PRINT(A + "
")
         A ← A + 1
    ENDWHILE
    PRINTLINE();
END MyMethod
Here is the equivalent C++ Code. Please read the code comments for more information
Give a thumbs up!!
Psuedocode
METHOD MAIN
CALL myMethod (0,2)
CALL myMethod (3,5)
CALL myMethod (6,7)
END MAIN
END MyMethodMETHOD myMethod(A,B)
BEGIN
    WHILE (A < B)
         PRINT(A + "
")
         A ← A + 1
    ENDWHILE
    PRINTLINE();
C++ Code
#include<iostream>
using namespace std;
//my method
void myMethod(int A,int B)
{
   while(A<B)
   {
       cout<<A<<" ";
       A=A+1;
   }
   cout<<endl;
}
int main()
{
   myMethod(0,2); //myMethod runs for 0 1
   myMethod(3,5);//myMethod runs for 3 4
   myMethod(6,7);//myMethod results 6
   return 0;
}
Screenshot of output
