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
Romashka [77]
3 years ago
15

What is the output of the following C++ program?

Computers and Technology
1 answer:
KIM [24]3 years ago
3 0

Answer:

Output:<em> </em><em>15 11/16 inches</em>

Explanation:

#include <iostream>

using namespace std;

////////////////////////////////////////////////////////////////////////

class InchSize {

public:

   InchSize(int wholeInches = 0, int sixteenths = 0);

   void Print() const;

   InchSize operator+(InchSize rhs);

   

private:

   int inches;

   int sixteenths;

};

InchSize InchSize::operator+(InchSize rhs) {

   InchSize totalSize;

   totalSize.inches = inches + rhs.inches;

   totalSize.sixteenths = sixteenths + rhs.sixteenths;

   

   // If sixteenths is greater than an inch, carry 1 to inches.

   if (totalSize.sixteenths >= 16) {

       totalSize.inches += 1;

       totalSize.sixteenths -= 16;

   }

   return totalSize;

}

InchSize::InchSize(int wholeInches, int sixteenthsOfInch) {

   inches = wholeInches;

   sixteenths = sixteenthsOfInch;

}

void InchSize::Print() const {

   cout<<inches<<" "<<sixteenths<<"/16 inches"<<endl;

}

////////////////////////////////////////////////////////////////////////

int main() {

   InchSize size1(5, 13);

   InchSize size2(9, 14);

   InchSize sumSize;

   sumSize = size1 + size2;

   sumSize.Print();

   return 0;

}

////////////////////////////////////////////////////////////////////////

sumSize variable was printed in the end. Print() prints the calling object's inches and sixteenths variables' values.

sumSize's inches is equal to size1 plus size2's inches.

Because the sum of sixteenths was greater than 16, sumSize's sixteenth was decreased by 1 and inches was increased by 1.

You might be interested in
Sara is asked to create a controller for light sensors. When the light falls on the sensor, it needs to indicate when a particul
Marrrta [24]

Answer:

Arduino

Explanation:

<em>Arduino is a free and open-source electronics platform with simple hardware and software. Arduino boards can read inputs, turn on a sensor and transform it into an output, activate a motor, and turn on an LED. Sara may direct her board by sending a series of instructions to the board's microcontroller. To accomplish so, she used the Arduino programming language and the Arduino Software (IDE), both of which are founded on Processing.</em>

7 0
1 year ago
The input to the following algorithm is a positive integer. The goal is to find the digit in the hundreds place of the integer.
Serggg [28]
The first division should reduce the hundreds digit to the units digit by dividing by 100.  Ignoring remainder means ignoring the previous units and tens digits.
The second division, where we keep the remainder is to extract the units digit by ignoring the quotient.  So we divide by 10.  The discarded digits are the tens and higher digits.

4 0
2 years ago
Read 2 more answers
) For a course with n students, an n X 3 array, int[][] arr, holds scores on 3 exams. Each row holds the exam scores for one stu
anzhelika [568]

Answer:

Following are the code to this question:

import java.util.*;//import package  

public class Main //defining a class

{

public static void main(String[] ax)//defining main method

{

      int student[][] = {{50,60,65},{75,85,90}}; //defining double array student  

      int Row=0,Col=0;//defining integer variable

      double x;//defining double variable

      for (int a = 0; a <student.length; a++)//use for loop to holding row value

       {  

           for (int b = 0; b<student[a].length; b++)//use for loop to holding column value  

           {  

               Row += student[a][b];//add row value

               Col += student[0][b];//add column value

           }

       }

       System.out.println(x=Row/2);//dividing value and calculating average value

}

}

Output:

212.0

Explanation:

In the above code, a 2D array student is declared, that holds some value in the next step, two integer variable "Row and Col", is declared, which it uses the for loop to add value in "Row and Col", and in the next step, a double variable x is declared, that add value and calculates its average value and store its value in x variable and print its value.

7 0
2 years ago
How many values will the user submit each time this form is used? Color: RedBlueGreen Quantity:
e-lub [12.9K]

Answer:

2

Explanation:

User submit quantity 2. with Color : Red Blue Green

7 0
2 years ago
Instructions:Select the correct answer from each drop-down menu. Which file types have .exe and .png as their extensions?
Gwar [14]
Programs are typically .exe and images are .png
4 0
3 years ago
Read 2 more answers
Other questions:
  • What is going to be the shortest, most concise restatement of information?
    10·2 answers
  • When is a wired connection preferred to a wireless connection by an end-user device?
    11·1 answer
  • To gain one pound of fat, how many extra calories would you need to consume?
    12·1 answer
  • Maya enjoys connectedWith her friends and social media apps but one of her friends post a lot of stuff that my thinks it’s annoy
    14·1 answer
  • How can I change it to accepted file types: .ppt, .pptx, .xls, .xlsx, .doc, .docx, .zip, .pdf, .accdb, .msg on Inkscape?
    15·2 answers
  • What are the basic tools for coding HTML manually?
    10·2 answers
  • Describe how layers in the ISO reference model correspond tolayers in the TCP/IP reference model.
    11·1 answer
  • which telecommunications service allows internet and telephone service to work over the same phone line
    13·1 answer
  • keeping in mind the role in order of precedence plays in equations, what would excel display as the result of the following equa
    14·1 answer
  • What stores all software and files on your computer and reads and writes data onto a spinning magnetic or optical disk?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!