Wednesday, June 30, 2010

// candyweight.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include
#include
using namespace std;

int main()
{
    cout << setw(4) << 5 << endl;
    cout << setw(4) << 25 << endl;
    double pay;
    pay = 10.50 * 23.333;
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    cout << "The pay is $" << pay << endl;
   

    // declare and initialize our variable
    int numBars;
    numBars=0;
    double barWeight = 0;
    cout << "Please enter # of bars & weight of 1 bar: ";
    cin >> numBars >> barWeight;
    // this is a comment!
   
    cout << "\a\a\a\"Total weight is " << numBars * barWeight << endl;
   
    cout << "Please enter # of bars & weight of 1 bar for another brand: ";
    cin >> numBars >> barWeight;
   
    cout << "Total weight is " << numBars * barWeight << "\n";

   
   
    return 0;
}


data type

4    int
4    long int
4.6    float
4.6    double
4.6    long double
"Josh"  string
true    bool
'x'    char

unsigned
signed
long
short


pico hello.cpp
g++ hello.cpp
./a.out

int numpods, peasperpod, total;
double temp;
string name;

hw:
write a prog.
variables: one, two, three, four, five
data type double
1.000, 1.414, 1.732, 2.000, 2.236

N    Square Root
1    1.000
2    1.414
3    1.732
4    2.000
5    2.236

Tuesday, June 29, 2010

assignment 1

1) write a prog which asks
for # of quarters, dimes,
and nickels. output total
value in cents

2)
distance = (acceleration X time^2)/2

prompt for: time in seconds
output: how far it would drop

there is constant acceleration of 32ft per second

Monday, June 28, 2010

Lecture 1

111 Algorithmic Problem Solving
program in C++

1 midterm, 1 final -- 70%, weighted toward the better score
labs -- 30%

1) C++ without fear
2) * Savitch
3) Schaum's outline programming with C++

von Neumann architecture
sequential access memory vs.
random access memory

scroll vs.
book

vhs tape vs. dvd

ram vs. disk

1. ask for a number
2. read in a #, call it x
3. ask for a number
4. read in a #, call it y
5. add x and y, put it in z
6. print out z
7. go to step 1

fetch-execute cycle

IP: 1
fetch an instruction from RAM, put it into the ALU
the ALU will execute the instruction
update the IP
fetch instruction....

computers only understand binary
0100100

10010010010010001110

machine language
assembly language

MOV AX, 6
ADD AX, 5
SUB BX, AX

MOV is 1001001
AX is 0001
BX is 1100
SUB is 10010


C++. closer to english

interpreted language
compiled language

main()
{
    int x, y, z;
    cin >> x >> y;
    z = x+y;
    cout << z << endl;   
}


venus

1. edit the source code
2. compile it
3. run it

IDE
integrated development environment

Microsoft Visual Studio


www.microsoft.com/express