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

No comments:

Post a Comment