Top Banner

Click here to load reader

of 30

Lecture 5: Expressions and Interactivity Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.

Jan 18, 2018

Download

Documents

Julian Phillips

// This program asks the user to enter the length and width of // a rectangle. It calculates the rectangle's area and displays // the value on the screen. #include using namespace std; int main() { int length, width, area; cout << "This program calculates the area of a "; cout << "rectangle. "; cout << "What is the length of the rectangle? "; cin >> length; cout << "What is the width of the rectangle? "; cin >> width; area = length * width; cout << "The area of the rectangle is " << area << ". "; return 0; }
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

Lecture 5: Expressions and Interactivity Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220 The cin Object The cout objects counterpart for input is cin Standard console input object Prompt the user for input >> stream extraction operator (remember > letter; cout