Use variables and assignments to compute the area of a rectangle and display the result. - C++ Data Type

C++ examples for Data Type:int

Description

Use variables and assignments to compute the area of a rectangle and display the result.

Demo Code

#include <iostream> 
 
int main() //from   w  w w .jav a2s.  c  om
{ 
    // set up width and length 
    unsigned short width = 26, length; 
    length = 40; 

    // create an unsigned short initialized with the 
    // result of multiplying width by length 
    unsigned short area = width * length; 

    std::cout << "Width: " << width << "\n"; 
    std::cout << "Length: "  << length << "\n"; 
    std::cout << "Area: " << area << "\n"; 
    return 0; 
}

Related Tutorials