Lecture-3 - ECE 3090 Software for Engineering Systems Prof...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 3090 Software for Engineering Systems Prof. Hongwei Wu School of Electrical and Computer Engineering Georgia Institute of Technology (Savannah)
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Today’s topics Standard Input Object: cin Mathematical Expressions More on Data Types Type Conversion Overflow and Underflow Ranks of Data Types Named constant Multiple Assignment and Combined Assignment Formatting Input and Output File Input and Output g++, makefile
Image of page 2
Standard input object: cin Used to read input from standard input device (usually keyboard) Stream extraction operator >> Inputs are stored in variables #include <iostream> when either cin or cout or both are used. always use cout to display a message before each cin statement. cin causes a program to wait until data is typed at the keyboard and the [Enter] key is pressed. cin automatically converts data to the type that matches the variable. 1. // This program asks the user to enter the length and width of 2. // a rectangle. It calculates the rectangle's area and displays 3. // the value on the screen. 4. #include <iostream> 5. using namespace std; 6. int main() 7. { 8. int length, width, area; 9. 10. cout << "This program calculates the area of a "; 11. cout << "rectangle.\n"; 12. cout << "What is the length of the rectangle? "; 13. cin >> length; 14. cout << "What is the width of the rectangle? "; 15. cin >> width; 16. area = length * width; 17. cout << "The area of the rectangle is " << area << ".\n"; 18. return 0; 19. }
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon