{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

02 C++ Basics and Input Output Full

02 C++ Basics and Input Output Full - Engineering101 C...

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style Engineering 101 C++ Basics and Input/Output
Background image of page 1

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

View Full Document Right Arrow Icon
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.
Background image of page 2
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) n Make sure you know how to submit your project
Background image of page 3

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

View Full Document Right Arrow Icon
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.
Background image of page 4
Our Algorithms Must Be Written  in a Programming Language n A programming language has precise  syntax   (grammar) and  semantics  (meaning). n An algorithm in a programming language is called  program . n To be used by the machine it must be translated  into a native language specific to the computer’s  CPU (central processing unit) called  machine  language . n This translation is done by a  compiler . n Writing directly in machine language is taxing for 
Background image of page 5

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

View Full Document Right Arrow Icon
Reading A C++ Program #include <iostream> using namespace std; int main ( ) { double x, y; cin   >> x; y = x * 7; cout << y; return 0;
Background image of page 6
#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.
Background image of page 7

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

View Full Document Right Arrow Icon
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
Background image of page 8
#include <iostream> using namespace std; int main ( ) { double x, y; cin   >> x; y = x * 7; cout << y; return 0; } Reading A C++ Program:  Declaration 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.
Background image of page 9

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

View Full Document Right Arrow Icon
#include <iostream> using namespace std; int main ( ) { double x, y; cin   >> x; y = x * 7; cout << y; return 0; } Reading A C++ Program:  Declaration 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 .
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}