Search
 
SCRIPT & CODE EXAMPLE
 

CPP

C++ Area of a Rectangle

    float length, width, area, perimeter;

    cout << "Input the length of a rectangle: ";
    cin >> length;
    cout << "Input the width of a rectangle: ";
    cin >> width;

    area = length * width;
    cout << "The area of a rectangle is " << area << endl;

    perimeter = length + length + width + width; // also >  2*(length + width)
    cout << "The perimeter of a rectangle is " << perimeter << endl;
Comment

PREVIOUS NEXT
Code Example
Cpp :: arduino led code 
Cpp :: how to display a variable in c++ 
Cpp :: c++ virtual function in constructor 
Cpp :: user input c++ 
Cpp :: quadratic problem solution c++ 
Cpp :: convert string to number c++ 
Cpp :: range of long long in c++ 
Cpp :: format c++ discord 
Cpp :: how to print fixed places after decimal point in c++ 
Cpp :: iterate vector from end to begin 
Cpp :: check if point is left or right of vector 
Cpp :: initializing 2d vector 
Cpp :: c++ how to check whether a file exists? 
Cpp :: cpp map iterate over keys 
Cpp :: c++ check if string is empty 
Cpp :: how to read a comma delimited file into an array c++ 
Cpp :: round double to n decimal places c++ 
Cpp :: character array to string c++ stl 
Cpp :: c++ check if char is number 
Cpp :: c++ struct with default values 
Cpp :: data types ranges c++ 
Cpp :: c++ char it is a number 
Cpp :: c++ function 
Cpp :: for loop in c++ 
Cpp :: overload stream extract cpp 
Cpp :: concatenate string program in c++ 
Cpp :: index string c++ 
Cpp :: c++ friend class 
Cpp :: how to dynamically allocate an array c++ 
Cpp :: factorial function c++ 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =