Question

7. Consider a function definition of calc Perimeter in the program segment given in Figure 17. float calcPerimeter (float wid

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

a)
float calcPerimeter(float width, float height, float &perimeter) {
    perimeter = 2*(width + height);
}

b)
float perimeter;
calcPerimeter(4, 7, perimeter);
cout << perimeter << endl;
Add a comment
Know the answer?
Add Answer to:
7. Consider a function definition of calc Perimeter in the program segment given in Figure 17....
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
  • 2. Write a program with three functions that will be called from the main function The functions will calculate the...

    2. Write a program with three functions that will be called from the main function The functions will calculate the volume, area and perimeter of a cuboid. You should able to pass three parameters such as length, width and height, and a function will return area, another will return volume and final one will return perimeter. Define all your variables in floating point numbers 3. Modify the problem#2 to calculate the volume, area and perimeter in a sing le function...

  • C++ 4. What is a driver program? 43. Consider the following function and code segment. void...

    C++ 4. What is a driver program? 43. Consider the following function and code segment. void Onet int first, int& second first 17 secondfirst 1 int main) // other code int j4; int k3; One(j, k) // other code .. After the call to OneGi, k); what are the values ofj and k?

  • 1. A(n) ____________________ is a variable or expression listed in a call to a function. 2....

    1. A(n) ____________________ is a variable or expression listed in a call to a function. 2. The pass by ____________________ mechanism must be used if the calling code is to receive information back from the function. 3. True or False? If there are several items in a parameter list, the compiler matches the parameters and arguments by their relative positions in the parameter and argument lists. 4. True or False? In C++, a function definition may have another function definition...

  • Q2) Interface Create a program that calculates the perimeter and the area of any given 2D...

    Q2) Interface Create a program that calculates the perimeter and the area of any given 2D shape. The program should dynamically assign the appropriate calculation for the given shape. The type of shapes are the following: • Quadrilateral 0 Square . Perimeter: 4xL • Area:LXL O Rectangle • Perimeter: 2(L+W) • Area:LxW Circle Circumference: I x Diameter (TT = 3.14) Area: (TT xD')/4 Triangle (assume right triangle) o Perimeter: a+b+c O Area: 0.5 x base x height (hint: the base...

  • I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the...

    I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the program until they enter "q" to quit. However, my program runs through one time, the prompt appears again, but then it terminates before the user is allowed to respond to the prompt again. I'm not able to debug why this...

  • Given that the following two function calls exist together in a single program

    6) Given that the following two function calls exist together in a single program -- which compiles and runs successfully, explain how the compiler can distinguish what function to call in each case. (Hint: There are at least two possible explanations...) func(a, b, c); func(a, b); 7) Write a function which will read in a phone number from the user and return it to the caller. The caller is expected to prompt the user before calling your function. The core code is given,...

  • Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO:...

    Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO: 1) Add the typedef here: 5// TODO: 2) Modify the parameter of repeat to add irn the function pointer for the function to be called repeatedly: 8 void repeat (int times) for (int k 0; k < times; ++k) 12 // TODO: 3) Add the call to the function pointer here: 14 15 17 void test (void) 18 printf("Test!\n"); 19...

  • The program must be in C# syntax. Write the definition for a generic class called Rectangle...

    The program must be in C# syntax. Write the definition for a generic class called Rectangle that has data members length and width. The class has the following member functions: setlength to set the length data member setwidth to set the width data member perimeter to calculate and return the perimeter of the rectangle area to calculate and return the area of the rectangle show to return a text to display the length and width of the rectangle sameArea that...

  • The program must be in C# syntax. Write the definition for a generic class called Rectangle...

    The program must be in C# syntax. Write the definition for a generic class called Rectangle that has data members length and width. The class has the following member functions: setlength to set the length data member setwidth to set the width data member perimeter to calculate and return the perimeter of the rectangle area to calculate and return the area of the rectangle show to return a text to display the length and width of the rectangle sameArea that...

  • a) 7% Define a function (the function definition only) named combine_lists that receives two lists of...

    a) 7% Define a function (the function definition only) named combine_lists that receives two lists of integers (the function has 2 parameters). You can assume that each list is the same length and each list is not empty. The function will create a new list which is composed of the addition of each element of the two lists. The function returns the new list. For example, if the function is sent this list: [2,4,6,8,10] and this list: [5,6,7,8,9] then the...

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
ADVERTISEMENT