Question: 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

Write a C++ program to find the area and perimeter of a

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

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include using namespace std int main ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!