# A Quick Look at C++

👁 88

statistics
by Dr. Osama M. Khaled
—
last modified
2022-09-26T21:19:07+00:00

A simple and basic C++ code example. Explore your logical understanding of programming wither you are a beginner or it is your first C++ encounter.

Questions #: 18

Time: 15 minutes

**Pass Score:**80.0%

Read through this program and answer the following questions

1 //**************************************************************2 // Given the length and width of a rectangle, this C++ program

3 // computes and outputs the perimeter and area of the rectangle.4 //**************************************************************

5

6 #include <iostream>

7 using namespace std;

8

9 int main()

10 {11 doublelength;

12 double width;13 doublearea;

14 double perimeter;

15

16 cout << "Program to compute and output the perimeter and " << "area of a rectangle." << endl;

17

19 length = 6.0;

20 width = 4.0;

21 perimeter = 2 * (length + width);

22 area = length * width;

23 cout << "Length = " << length << endl;

24 cout << "Width = " << width << endl;

25 cout << "Perimeter = " << perimeter << endl;

26 cout << "Area = " << area << endl;

27 return 0;

28 }

Views:

Trials:

Avg score: