02 C++ Basics and Input Output Full

02 C++ Basics and Input Output Full - Click to edit Master...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Click to edit Master subtitle style Engineering 101 C++ Basics and Input/Output Quote of the Day- Confucius The people may be made to follow a path of action, but they may not be made to understand it. Announcements n Exit strategy! n 2 exits at the front of the class n 2 exits at the sides of the class n 1 exit at the rear of the aircraft class n Office hours are posted on Ctools n Some need to be added still n Project 1 is posted n Due Wednesday, 1/14 at 11pm (not 9pm) From Algorithms To Programs n So far we have described a few algorithms in pseudo-code. n Pseudo-code is fine for communicating algorithms between people but it is not precise enough to be used by a computer. Our Algorithms Must Be Written n A programming language has precise syntax (grammar) and semantics (meaning). n An algorithm in a programming language is called a program . n To be used by the machine it must be translated into a native language specific to the computers CPU (central processing unit) called machine language . n This translation is done by a compiler . Reading A C++ Program #include <iostream> using namespace std; int main ( ) { double x, y; cin >> x; y = x * 7; cout << y; #include <iostream> using namespace std; int main ( ) { double x, y; cin >> x; y = x * 7; cout << y; return 0; } Reading A C++ Program n Much of this program is scaffolding . n Scaffolding is only important insomuch as it holds the program together and provides context for the C++ compiler. n We will consider this part of the program soon. n The remaining part of the code consists of only 4 lines. n The code reads in a number and then writes the result of multiplying the number by 7. #include <iostream> using namespace std; int main ( ) { double x, y; cin >> x; y = x * 7; cout << y; return 0; } Reading A C++ Program #include <iostream> using namespace std; int main ( ) { double x, y; cin >> x; y = x * 7; cout << y; return 0; } Reading A C++ Program: n The first line of the body declares two containers to hold numbers. n The identifiers of these containers will be x and y . n It is important to declare every identifier before it is used. #include <iostream> using namespace std; int main ( ) { double x, y; cin >> x; y = x * 7; cout << y; return 0; } Reading A C++ Program: n Simple declarations are of the form: simple_type identifiers; n In this case the identifiers x and y are declared to be of the type double ....
View Full Document

This note was uploaded on 04/07/2010 for the course ENGR engr 101 taught by Professor Rinenberg during the Spring '10 term at University of Michigan.

Page1 / 90

02 C++ Basics and Input Output Full - Click to edit Master...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online