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
One method that is used to grow nanowires (nanotubes with solid cores) is to initially deposit a small droplet of a liquid catal
7nadin3 [17]

Answer: maximum length of the nanowire is 510 nm

Explanation:

 

From the table of 'Thermo physical properties of selected nonmetallic solids at At T = 1500 K

Thermal conductivity of silicon carbide k = 30 W/m.K

Diameter of silicon carbide nanowire, D = 15 x 10⁻⁹ m  

lets consider the equation for the value of m

m = ( (hP/kAc)^1/2 )  = ( (4h/kD)^1/2 )  

m =  ( ((4 × 10⁵)/(30×15×10⁻⁹ ))^1/2 ) = 942809.04    

now lets find the value of h/mk    

h/mk = 10⁵ / ( 942809.04 × 30) =  0.00353

lets consider the value θ/θb by using the equation

θ/θb = (T - T∞) / (T - T∞)

θ/θb =  (3000 - 8000) / (2400 - 8000)

= 0.893

the temperature distribution at steady-state is expressed as;

θ/θb = [ cosh m(L - x) + ( h/mk) sinh m (L - x)]   / [cosh mL+  (h/mk) sinh mL]

θ/θb = [ cosh m(L - L) + ( h/mk) sinh m (L - L)]   / [cosh mL+  (h/mk) sinh mL]

θ/θb = [ 1 ]  / [cosh mL+  (h/mk) sinh mL]

so we substitute

0.893 =  [ 1 ]  / [cosh (942809.04 × L) +  (0.00353) sinh (942809.04 × L)]

L = 510 × 10⁻⁹m

L = 510 nm

therefore maximum length of the nanowire is 510 nm

4 0
3 years ago
Does anybody know what plane this is? i saw it the other day doing a low pass through my community
Arlecino [84]

Answer:

Airbus A340-313

Explanation:

it is what it is

3 0
2 years ago
What is the difference between a discrete and continuous system?
Serjik [45]

Answer:Discrete system are those system which change the state at the discrete point of time and continuous system are those which have state change at continuous period of time.

Explanation:

  • The major difference between discrete and continuous system is that, discrete system has state change over a discontinuous time period whereas the change of state in continuous system is over a continuous time period .
  • Variations can be found in the discrete system signal but  in continuous system variation cannot be found input and output signal.
  • Example:-

       Discrete system:-employees reporting at office at different time like

       9:10am, 9:15am etc              

       <u> Continuous system</u>:-the water flow over a dam in particular quantity                    

7 0
3 years ago
(Gas Mileage) Drivers are concerned with the mileage their automobiles get. One driver has kept track of several trips by record
Effectus [21]

Answer:

import java.util.*;

public class Main {

   

   public static void main(String[] args) {

     

       double milesPerGallon = 0;

       int totalMiles = 0;

       int totalGallons = 0;

       double totalMPG = 0;

       

       Scanner input = new Scanner(System.in);

 

       while(true){

           System.out.print("Enter the miles driven: ");

           int miles = input.nextInt();

           if(miles <= 0)

               break;

           else{

               System.out.print("Enter the gallons used: ");

               int gallons = input.nextInt();

               totalMiles += miles;

               totalGallons += gallons;

               milesPerGallon = (double) miles/gallons;

               totalMPG = (double) totalMiles / totalGallons;

               System.out.printf("Miles per gallon for this trip is: %.1f\n", milesPerGallon);

               System.out.printf("Total miles per gallon is: %.1f\n", totalMPG);

           }

       }

   }  

}

Explanation:

Initialize the variables

Create a while loop that iterates until the specified condition is met inside the loop

Inside the loop, ask the user to enter the miles. If the miles is less than or equal to 0, stop the loop. Otherwise, for each trip do the following: Ask the user to enter the gallons. Add the miles and gallons to totalMiles and totalGallons respectively. Calculate the milesPerGallon (divide miles by gallons). Calculate the totalMPG (divide totalMiles by totalGallons). Print the miles per gallon and total miles per gallon.

6 0
3 years ago
Thank you very much this helped a lot
Len [333]

Answer:

Your welcome i guess

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • A hollow aluminum sphere, with an electrical heater in the center, is used in tests to determine the thermal conductivity of ins
    6·1 answer
  • As shown, a load of mass 10 kg is situated on a piston of diameter D1 = 140 mm. The piston rides on a reservoir of oil of depth
    9·1 answer
  • What type of drawing would civil engineers use if they needed to show an
    11·1 answer
  • Water flows through a horizontal 60 mm diameter galvanized iron pipe at a rate of 0.02 m3/s. If the pressure drop is 135 kPa per
    9·1 answer
  • What is 203593^54/38n^7
    6·1 answer
  • What combustion after effects do actuators work to control
    15·2 answers
  • 1. When and why should we use the Pattern option?
    12·1 answer
  • Please help me. I have no idea what I'm doing.​
    14·2 answers
  • When cutting a FBD through an axial member, assume that the internal force is tension and draw the force arrow _______ the cut s
    11·1 answer
  • Read the passage.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!