Question

Convert the below 3 statements in English to c++ equivalent. a) The area of a rectangle is given as area = width x height You
0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a) The area of a rectangle is given as area=width*height
You are given the variable double A,wd,ht.
  
C++ Statement:- double A,wd,ht;
A=wd*ht;


(b) The Surface area of a cube is given as area=2ab+2ac+2bc
where a,b,c are the lenght,width and height.
you are given the variable double A,a,b,c.
  
C++ Statement:- double A,a,b,c;
A= 2*a*b + 2*a*c + 2*b*c;
  

(c) The volume of a regular pyramid is given as V=(1/3)(w*l*h).
You are given the variable double V,w,l,h;

C++ Statement:- double V,w,l,h;
V= (w*l*h)/3.0;

Add a comment
Know the answer?
Add Answer to:
Convert the below 3 statements in English to c++ equivalent. a) The area of a rectangle...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using basic c++ write a separate code for each of the following: 1. Area Rectangle •...

    Using basic c++ write a separate code for each of the following: 1. Area Rectangle • Write a program that asks the user to enter length and width of a rectangle and then display the rectangles area. • Write the following functions • getLength – prompt the user to enter length and return that value as a double • getWidth – prompt the user to enter width and return that value as a double • getArea – This method should...

  • java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectang...

    java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...

  • Define an interface named Shape with a single method named area that calculates the area of...

    Define an interface named Shape with a single method named area that calculates the area of the geometric shape:        public double area(); Next, define a class named Circle that implements Shape. The Circle class should have an instance variable for the radius, a constructor that sets the radius, an accessor and a mutator method for the radius, and an implementation of the area method. Define another class named Rectangle that implements Shape. The Rectangle class should have instance variables...

  • please answer all C. 2. What rectangle has the smallest perimeter, for a given area? Suppose...

    please answer all C. 2. What rectangle has the smallest perimeter, for a given area? Suppose you want a rectangle with area 200. What choice of length L and width W will give the smallest perimeter? a. Sketch a rectangle and label it as having length L and width W. b. Write the area in terms of length and width: A = Write the perimeter in terms of length and width: P = d. If L = 200 and W...

  • Hey I'm trying to convert this C code into ARMv8 however I'm having severe difficulty while...

    Hey I'm trying to convert this C code into ARMv8 however I'm having severe difficulty while doing it. This is just for personal practice to develop my skills. Thank you! // Code starts here // This is a C language code below #define FALSE 0 #define TRUE 1 struct coord { int x, y; }; struct size { int width, length; }; struct pyramid { struct coord center; struct size base; int height; int volume; }; struct pyramid newPyramid(int width,...

  • in C++ use Inheritance for the following Shape Circle Sphere Cylinder Rectangle Square Cube You must define one class for each shape. And, use public inheritance when deriving from base cla...

    in C++ use Inheritance for the following Shape Circle Sphere Cylinder Rectangle Square Cube You must define one class for each shape. And, use public inheritance when deriving from base classes. Circle int r; void area(); void perimeter(); void volume(); //No volume for circle Sphere int r; void area();//Sphere surface area= 4 × pi × radius2 void perimeter(); //No perimeter for Sphere void volume();//Sphere volume= 4/3 × pi × radius2 Cylinder int r, height; void area();// Cylinder surface area=perimeter of...

  • Question 4.4: Write an overloaded function of function area with 3 (float) parameters. This function should...

    Question 4.4: Write an overloaded function of function area with 3 (float) parameters. This function should calculate and print out the product of the 3 parameters. Question 4.4: Write the main function to test question 4.1, 4.2, 4.3, 4.4. Your main function should ask if the user want to calculate the area of a rectangle or a circle or a triangle then print out the result accordingly. (Use switch structure). For example: Please enter (r) for rectangle, (t) for triangle,...

  • For this lab you will be creating a class representing the shape square. A Square is...

    For this lab you will be creating a class representing the shape square. A Square is a special case of a Rectangle where both sides have the same length. Rectangle has been provided for your use in this lab. A Rectangle has a height and a width as member variables, two constructors, two member functions, area() and perimeter(), and lastly, an input and output operator. Your Square class should publicly inherit from Rectangle. You will need to update the Constructors...

  • Question 1- part-1) Provide complete UML class diagrams for the Polygon and Rectangle classes, including access...

    Question 1- part-1) Provide complete UML class diagrams for the Polygon and Rectangle classes, including access specifiers, parameters, and data/return types. Include the relationship between these two classes in the diagram. And then, Question 1-part-2) Given the following reference variable declaration and object assignment: Polygon poly = new Rectangle(); What would happen given each of the following two lines of code? Briefly explain your answer. System.out.println(poly); double area = poly.getArea(); Then tell me what is the major difference between abstract...

  • 8. Find the surface area of the part of the plane z+y+z4 over the rectangle [0, 1]x[0,2 b) 3 c) 2...

    8. Find the surface area of the part of the plane z+y+z4 over the rectangle [0, 1]x[0,2 b) 3 c) 2v3 d) 8 e) 12 8. Find the surface area of the part of the plane z+y+z4 over the rectangle [0, 1]x[0,2 b) 3 c) 2v3 d) 8 e) 12

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT