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
Saul is testing an installation and discovers a short circuit. What's causing this?
sergey [27]
A high voltage!! Hope this helps
6 0
3 years ago
1. One of these is NOT a type of pneumatic tool. Which one?
Serggg [28]

Answer:Circular

Explanation:

It’s the only thing not list under pneumatic tools‍♂️

5 0
3 years ago
How can I find the quotient of 27 divided 91.8
gayaneshka [121]
Step 1:
Start by setting it up with the divisor 8 on the left side and the dividend 27 on the right side like this:

8 ⟌ 2 7

Step 2:
The divisor (8) goes into the first digit of the dividend (2), 0 time(s). Therefore, put 0 on top:

0
8 ⟌ 2 7

Step 3:
Multiply the divisor by the result in the previous step (8 x 0 = 0) and write that answer below the dividend.

0
8 ⟌ 2 7
0

Step 4:
Subtract the result in the previous step from the first digit of the dividend (2 - 0 = 2) and write the answer below.

0
8 ⟌ 2 7
- 0
2

Step 5:
Move down the 2nd digit of the dividend (7) like this:

0
8 ⟌ 2 7
- 0
2 7

Step 6:
The divisor (8) goes into the bottom number (27), 3 time(s). Therefore, put 3 on top:

0 3
8 ⟌ 2 7
- 0
2 7

Step 7:
Multiply the divisor by the result in the previous step (8 x 3 = 24) and write that answer at the bottom:

0 3
8 ⟌ 2 7
- 0
2 7
2 4

Step 8:
Subtract the result in the previous step from the number written above it. (27 - 24 = 3) and write the answer at the bottom.

0 3
8 ⟌ 2 7
- 0
2 7
- 2 4
3

You are done, because there are no more digits to move down from the dividend.

The answer is the top number and the remainder is the bottom number.

Therefore, the answer to 27 divided by 8 calculated using Long Division is:

3
8 0
3 years ago
The supplement file* that enclosed to this homework consists Time Versus Force data. The first column in the file stands for tim
AysviL [449]

Answer:

A.) 1mv = 2000N

B.) Impulse = 60Ns

C.) Acceleration = 66.67 m/s^2

Velocity = 4 m/s

Displacement = 0.075 metre

Absorbed energy = 60 J

Explanation:

A.) Using a mathematical linear equation,

Y = MX + C

Where M = (2000 - 0)/( 898 - 0 )

M = 2000/898

M = 2.23

Let Y = 2000 and X = 898

2000 = 2.23(898) + C

2000 = 2000 + C

C = 0

We can therefore conclude that

1 mV = 2000N

B.) Impulse is the product of force and time.

Also, impulse = momentum

Given that

Mass M = 30kg

Velocity V = 2 m/s

Impulse = M × V = momentum

Impulse = 30 × 2 = 60 Ns

C.) Force = mass × acceleration

F = ma

Substitute force and mass into the formula

2000 = 30a

Make a the subject of formula

a = 2000/30

acceleration a = 66.67 m/s^2

Since impulse = 60 Ns

From Newton 2nd law,

Force = rate of change in momentum

Where

change in momentum = -MV - (- MU)

Impulse = -MV + MU

Where U = initial velocity

60 = -60 + MU

30U = 120

U = 120/30

U = 4 m/s

Force = 2000N

Impulse = Ft

Substitute force and impulse to get time

60 = 2000t

t = 60/2000

t = 0.03 second

Using third equation of motion

V^2 = U^2 + 2as

Where S = displacement

4^2 = 2^2 + 2 × 66.67S

16 = 4 + 133.4S

133.4S = 10

S = 10/133.4

S = 0.075 metre

D.) Energy = 1/2 mV^2

Energy = 0.5 × 30 × 2^2

Energy = 15 × 4 = 60J

5 0
3 years ago
Assume a program contains a void function named calcNewPrice(). The function receives two double variables named oldPrice and ne
liberstina [14]

Answer:

(C) calcNewPrice(oldPrice, &newPrice);

Explanation:

It's a void function so there's no return value, however they wanted to change a value. The only way to do that is to pass in an address of the variable into the function, and deference it and store the new data there.

4 0
3 years ago
Other questions:
  • A hypodermic syringe is used to apply a vaccine. If the plunger is moved forward at the steady rate of 20 mm/s and if vaccine le
    14·1 answer
  • Nearly__________ of all serious occupational injuries and illnesses stem from overexertion of repetitive motion.a. 1/2b. 1/4c. A
    10·1 answer
  • Experimental Design Application Production engineers wish to find the optimal process for etching circuit boards quickly. They c
    10·1 answer
  • Write a single statement to print: user_word,user_number. Note that there is no space between the comma and user_number. Sample
    7·1 answer
  • Write a function call with arguments tensPlace, onesPlace, and userInt. Be sure to pass the first two arguments as pointers. Sam
    11·1 answer
  • 2.(10 pts)A proposed engine cycle employs an ideal gas and consists of the following sequence of transformations; a) Isothermal
    12·1 answer
  • Ok there........................................................................
    12·1 answer
  • Cual es el impacto medioambiental del mortero?
    11·1 answer
  • A farmer has 19 sheep on his land. One day, a big storm hits and all but seven run away. How many sheep does the farmer have lef
    10·1 answer
  • Which of the following is true about modern hydraulic lifts?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!