Write a C++ program to find the area and perimeter of a rectangle. area= length*width; perimeter=2(length+width);...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C++ program to find the area and perimeter of a rectangle. area= length*width; perimeter=2(length+width); Note: This program should use pointers (new). You have to de-allocate the memory using delete operator. Check your program that it should not have memory leaks or bad memory/cheap memory. Use valgrind to check the memory leaks. See the commands below for compiling and executing your code. Sample Output 1 kc@kc-VirtualBox:/media/shared_dirs g++-g Worksheet8.cpp kc@kc-VirtualBox:/media/shared_dirs valgrind --leak-check-full -s./a.out ==3687== Memcheck, a memory error detector ==3687== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==3687== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info ==3687== Command: ./a.out ==3687== Enter the length 7.5 Enter the width 2.5 Area of 7.5 and 2.5 is: 18.75 Perimeter of 7.5 and 2.5 is: 20 ==3687== ==3687== HEAP SUMMARY: ==3687== in use at exit: 0 bytes in 0 blocks ==3687== total heap usage: 7 allocs, 7 frees, 74,882 bytes allocated ==3687== ==3687== All heap blocks were freed -- no leaks are possible ==3687== ==3687== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) kc@kc-VirtualBox:/media/shared_dirS Write a C++ program to find the area and perimeter of a rectangle. area= length*width; perimeter=2(length+width); Note: This program should use pointers (new). You have to de-allocate the memory using delete operator. Check your program that it should not have memory leaks or bad memory/cheap memory. Use valgrind to check the memory leaks. See the commands below for compiling and executing your code. Sample Output 1 kc@kc-VirtualBox:/media/shared_dirs g++-g Worksheet8.cpp kc@kc-VirtualBox:/media/shared_dirs valgrind --leak-check-full -s./a.out ==3687== Memcheck, a memory error detector ==3687== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==3687== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info ==3687== Command: ./a.out ==3687== Enter the length 7.5 Enter the width 2.5 Area of 7.5 and 2.5 is: 18.75 Perimeter of 7.5 and 2.5 is: 20 ==3687== ==3687== HEAP SUMMARY: ==3687== in use at exit: 0 bytes in 0 blocks ==3687== total heap usage: 7 allocs, 7 frees, 74,882 bytes allocated ==3687== ==3687== All heap blocks were freed -- no leaks are possible ==3687== ==3687== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) kc@kc-VirtualBox:/media/shared_dirS
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Find the area and perimeter of each square. 1. 2. 9 centimeters 41 feet
-
Write a Java program to print the area and perimeter of a circle.
-
Write a Java program to print the area and perimeter of a rectangle.
-
Perpetual inventory using FIFO Beginning inventory, purchases, and sales for Item Zeta9 are as follows: Oct. 1 Inventory 37 units @ $19 Oct. 7 Sale Oct. 15 Purchase Oct. 24 Sale Assuming a perpetual...
-
An experiment with three outcomes has been repeated 50 times, and it was learned that E1 occurred 20 times, E2 occurred 13 times, and E3 occurred 17 times. Assign probabilities to the outcomes. What...
-
At week 24 of a project to shoot a television commercial, what should the expenditures be? If the earned value is right on schedule but the actual expenses are $9,000, what are the cost and schedule...
-
It takes an electric field magnitude of about \(10^{6} \mathrm{~V} / \mathrm{m}\) to ionize atoms in the air and produce a spark. Is it possible to increase the magnetic field inside a long solenoid...
-
Garry Pipers rich uncle gave him $80,000 cash as a gift for his 40th birthday. Unlike his spoiled cousins who spend money carelessly, Mr. Piper wants to invest the money for his future retirement....
-
17. Moment of inertia (M.I) of four bodies, having same mass and radius, and reported as: I1 = M.I. of thin circular ring about its diameter 18. 12 = M.I. of circular disc about an axis perpendicular...
-
Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER (OwnerID, OwnerName, OwnerEmail, OwnerType) OWNED_PROPERTY (PropertyID, PropertyName,...
-
Given data below. From To Materials Welding Drills Lathes Grinders Benders Materials 0 100 55 0 0 45 Welding 25 0 0 50 0 0 Drills 20 0 0 0 50 0 Lathes 0 30 0 0 15 0 Grinders 55 0 70 0 0 0 Benders 15...
-
Are you convinced by the economists' arguments of the extent to which factor substitution and technological advances can be used to ameliorate the scarcity of environmental resources? Provide...
-
What is the bid-ask spread?
-
Professional behaviour means that members of the professional body must: a. maintain their knowledge and skill at the required level. b. keep up to date with changes in regulations and standards. c....
-
Economics is said to be the study of choices that implies trade-offs. Viewed broadly, what is the specific trade-off involved when the environment is the focus of an eco- nomic study?
-
Economists view environmental resources or the natural environment, in general, as a scarce resource. In what specific way is the natural environment regarded as a scarce resource?
-
what is the Low velocity zone? 1. elsic 2. Mafic 3. Partially melted rock 4. Crust 5. Pressure causes olivine to change to spinel 6. Physical boundary 7. core
-
The trade-off theory relies on the threat of financial distress. But why should a public corporation ever have to land in financial distress? According to the theory, the firm should operate at the...
-
Finesse Fitness was established on 1 April 2024 with an initial investment of $60000 by the owner, Daniel Hewitt. During the first few months of business, the owner employed a student studying...
-
Jason Vu offers tutoring services to first-year university students. He has set up a sole proprietorship business named JV Tutoring. Jason has collected the following information relating to his...
-
Yamindi was raised on a farm in the Northern Territory and loves animals. When he finished secondary school, Yamindi had nearly \($5000\) in a savings account. He used his savings to start a business...
Study smarter with the SolutionInn App