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

I asked these questions yesterday but some of them were written incorrectly. All

ID: 3581780 • Letter: I

Question

I asked these questions yesterday but some of them were written incorrectly. All I need is the output for these said questions. Thanks a lot :)

1.)

#include <iostream>

using namespace std;

int main()

{

int x, y;

x=10;

y=15;

if(x>=9)

{

x=x+y;

y++;

}

else

{

x=x-y;

y--;

}

}

2.)

#include <iostream>

using namespace std;

int main()

{

int x, y;

x=30;

y=20;

if(x<y)

{

x=x*3;

y=y*2;

}

else

{

x=x/3;

y=y/2;

}

}

3.)

#include <iostream>

using namespace std;

int main()

{

int x = 8;

int y = 3;

y = x - y;

if(x<2)

{

x--;

y--;

}

else if (x>=5)

{

x++;

y++;

}

else

{

x=200;

y=400;

}

}

4.)

#include <iostream>

using namespace std;

int main()

{

int x = 22;

int y = 20;

y = y-x;

x=x-y;

if(x<=20)

{

x = y-x;

y=y+x;

}

else

{

x = y+x;

y=y-x;

}

}

Explanation / Answer

// 1) c++ code
#include <iostream>
using namespace std;
int main()
{
   int x, y;
   x=10;
   y=15;

   if(x >= 9)
   {
       x=x+y;
       y++;
   }
   else
   {
       x=x-y;
       y--;
   }

   cout << "x: " << x << endl;
   cout << "y: " << y << endl;

   return 0;
}

/*
output:

x: 25
y: 16

*/


// 2) c++ code
#include <iostream>
using namespace std;
int main()
{
   int x, y;
   x=30;
   y=20;
   if(x<y)
   {
       x=x*3;
       y=y*2;
   }
   else
   {
       x=x/3;
       y=y/2;
   }

   cout << "x: " << x << endl;
   cout << "y: " << y << endl;

   return 0;
}

/*
output:

x: 10
y: 10

*/


// 3) c++ code
#include <iostream>
using namespace std;
int main()
{
   int x = 8;
   int y = 3;
   y = x - y;
   if(x<2)
   {
       x--;
       y--;
   }
   else if (x>=5)
   {
       x++;
       y++;
   }
   else
   {
       x=200;
       y=400;
   }

   cout << "x: " << x << endl;
   cout << "y: " << y << endl;

   return 0;
}

/*
output:

x: 9
y: 6

*/


// 4) c++ code
#include <iostream>
using namespace std;
int main()
{
   int x = 22;
   int y = 20;
   y = y-x;
   x=x-y;
   if(x<=20)
   {
       x = y-x;
       y=y+x;
   }
   else
   {
       x = y+x;
       y=y-x;
   }

   cout << "x: " << x << endl;
   cout << "y: " << y << endl;

   return 0;
}

/*
output:

x: 22
y: -24

*/

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