1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
a_sh-v [17]
4 years ago
6

1 // Lab 2 tryIt2A 2 #include 3 using namespace std; 4 5 int main() 6 { int x = 1, y = 3; 7 int X = 2, Y = 4; 8 9 cout <<

"tryIt 2A" <

Engineering
1 answer:
padilas [110]4 years ago
6 0

Answer:

Here is the complete program:

#include <iostream>

 using namespace std;    

 int main()

 {  int x = 1, y = 3;  

 int X = 2, Y = 4;  

 cout << "tryIt 2A" <<endl;

   cout << x << y << endl;  

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

   cout << X << " " << Y << endl;

   cout << 2 * x + y << endl;  

   cout << 2 * X + Y << endl;  

   //cout << x + 2*y << endl;  

   cout << "x = ";  

   cout << x;  

   cout << " y = ";  

   cout << y;        

   return 0;

   }

Explanation:

I will explain the code line by line in the comment with each line of code and the output of each cout statement.

  • int x = 1, y = 3;  

This statement assigns value 1 to integer variable x and 3 to int variable y

  • int X = 2, Y = 4;  

This statement assigns value 2 to integer variable X and 4 to int variable Y As C++ is a case sensitive language so variable x and y are different from variables X and Y.

  • cout << "tryIt 2A" <<endl;

This statement has cout which is used to display output on the screen. So the output displayed by this cout statement is:

tryIt2A

  • cout << x << y << endl;  

This statement will print the values stored in x and y variables. So output displayed by cout statement here is 1 and 3. As there is not space or next line specified in the statement so output displayed will look like this:

13

  • cout << "x" << "y" << endl;  

This statement will display x and y but these are not the variable x and y. They are enclosed in double quotation marks so they are treated as strings not variables so the output displayed is:

xy

  • cout << X << " " << Y << endl;

This statement will print the values stored in X and Y variables. So output displayed by cout statement here is 2 and 4. As there is  space " " specified in the statement so 2 and 4 are displayed with a space between them so the output displayed will look like this:

2 4

  • cout << 2 * x + y << endl;  

This statement has an arithmetic operation in which 2 is multiplied by the values stored in variable x and then the result is added by value of y. So  2*1 = 2 and 2 + 3 = 5. So the result produced by this cout statement is:

5

  • cout << 2 * X + Y << endl;  

This will work same as above cout statement but the only difference is that the values of capital X and Y variables are calculated here. So 2 * 2 = 4 and then 4 + 4 = 8. The result produced by this cout statement is:

8

  • //cout << x + 2*y << endl;  

This is a comment because before this statement // is written which is used for single line comment. So compiler ignores comments and will not compile this statement.

  •    cout << "x = ";  

This will display "x = " as it is not variable but it is treated as a line to be displayed on the screen. So cout statement displays:

x =

  • cout << x;

This will print the value stored in x variable as there are no double quotes around x so it is a variable which contains value 1. In the above statement there is no endl so the output of this cout statement is displayed with the output of previous cout statement. So the following line is displayed on screen:

x = 1

  • cout << " y = ";

This will display "y = " as it is not variable but it is treated as a line to be displayed on the screen. In the above statement there is no endl so the output of this cout statement is displayed with the output of previous cout statement. So the following line is displayed on screen

x = 1 y =

  • cout << y;    

This will print the value stored in y variable as there are no double quotes around y so it is a variable which contains value 3. In the above statement there is no endl so the output of this cout statement is displayed with the output of previous cout statement. So the following line is displayed on screen:

x = 1 y = 3

So the output of the entire program along with the program is attached as screenshot.

You might be interested in
HELP PLEASE!!!!
DaniilM [7]

Answer:

DESCULPA MAS EU NÃO ENTENDI

8 0
3 years ago
What is the derivative of?
Wewaii [24]

Answer:

cot(x)

Explanation:

\frac{d}{dx}ln(sin(x))

Use u-substitution,

u=sin(x)\\u'=cos(x)

\frac{d}{dx}ln(sin(x)) = \frac{d}{du}ln(u)

= \frac{1}{u}u'     //using the chain rule

= \frac{1}{sin(x)}cos(x)

=cot(x)

6 0
3 years ago
Ok this really isn’t a question but I need help, I’m wondering if a Samsung galaxy 9 is a good phone
Savatey [412]

Answer:

yes it is

Explanation:

it's an extremely good phone in my opinion

7 0
3 years ago
Read 2 more answers
Technician A says that the connecting rod and main bearing caps should be marked before removing to ensure that they can be inst
Rama09 [41]

Answer:

Technician A

Explanation:

This is because when the dimacations are made, the surface area and length respectively can be maintained to reduce to idea of force which may lead to damage

3 0
2 years ago
Compare the output of full-wave rectifier with and without filter
lara31 [8.8K]

Answer:

Full wave rectification flips the negative half cycle of the sine wave to positive so the result is two positive half cycles.

Explanation:

hope it helps a lil

4 0
3 years ago
Other questions:
  • The revolving part of a rotating electrical machine. The rotor may be either the field or the armature, depending on the design
    15·1 answer
  • The impeller shaft of a fluid agitator transmits 28 kW at 440 rpm. If the allowable shear stress in the impeller shaft must be l
    6·1 answer
  • Mahamad Siddiqui sent false emails and letters of recommendation on behalf of individuals without their permission to nominate h
    12·1 answer
  • Witch part of the testing and evaluation stage of designing a PDA
    9·1 answer
  • Which is one factor that scientists use to classify orders of soil?Which phrase best describes the biosphere?
    9·1 answer
  • A(n) ____ is an object setting used to control the visible display of objects.
    15·1 answer
  • Forcing a solid piece of heated aluminum through a die forms:
    15·2 answers
  • In approximately 200 words, explain what three factors you believe will have the greatest impact on the future of the green buil
    11·1 answer
  • What is the sum of A+B+ C
    13·1 answer
  • Engineering Specificaitons is ...
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!