In order to get the values of material cost, material content of parts, etcetera, into the storage locations, you need to know about input and output (IO).
steel_cost,
(containing the cost of steel per kg or lb),
part_steel_content, (containing the amount of steel in the
part being computed), and part_material_cost, (containing
the total cost of material, just steel for now, for the part being
computed.) (25%)
part_material_cost now should contain the total cost of
material, both steel and aluminum, for the part being computed.
You also will need to define additional variable names. (25%)
Select the best answer:
Select the best answer:
cout << "H" << "el" << 'l' << 'o' << endl;
Hello
H el l o
"H" << "el" << 'l' << 'o' << endl
cout << "0.500 = " << 0.500 << endl;
0.500 = 0.500
0.5 = 0.5
0.500 = 0.5
cout << "Line 1\nLine 2\n"; cout << "Line 1\n";
cout << "Line 2\n";
cout << "Line 1\n"; cout << "Line 1" << endl
cout << "Line 2\n"; << "Line 2" << endl;
cout
is missing.
cout << "\a" << "Hi" << "there" << endl;
(Does not work on the PCs, but works on Unix.)
\a Hi there
\aHithere
Hithere
and the computer beeps.
#include <iostream.h> #include <iostream.h>
void main(void) { void main(void) {
int a; int a;
... int b;
int b; ...
... ...
a=1; a=1;
b=3; b=3;
cout << a+b << endl; cout << a+b << endl;
... ...
} }
(The dots stand for lots of other statements that are not important.)
b if all declarations are grouped together.
#include <iostream.h>
void main(void) {
int pi;
...
pi = 3.141593;
...
}
include line.
pi = 3.141593; will crash.
pi is set to 3, not to 3.141593
#include <iostream.h> #include <iostream.h>
void main(void) { void main(void) {
float pi = 3.141593; float pi;
.... ....
.... pi=3.141593
.... ....
area = pi*r*r area = pi*r*r
.... ....
pi has been
given the right value.
pi a value early, it will be sure to have
received the value by the time we reach the area=
statement.
#include <iostream.h> #include <iostream.h>
void main(void) { void main(void) {
// Declarations: // Declarations:
// Define pi: float pi = 3.141593; // pi is defined
float pi = 3.141593; ....
.... ....
cout << "3*3 = " << 3*3 << endl;
3*3 = 3*3
9 = 9
3*3 = 9
float a; ...; a=1.5; cout << a << endl;
int a; ...; a=1.5; cout << a << endl;
cout << ".33 = " << 1/3 << endl;
.33 = 0
.33 = .33
.33 = .3333333
cout << ".33 = " << 1./3 << endl;
.33 = 0
.33 = .33
.33 = .3333333
cout << "Large: " << 300000*300000 << endl;
Large: 300000*300000
Large: 90000000000
cout << "9 = " << 1+2*3 << endl;
9 = 1+2*3
9 = 9
9 = 7
cout << ".25 = " << 1./2.*2. << endl;
.25 = 1./2.*2.
.25 = .25
.25 = 1.
cout << "1 = " << 1./2./2. << endl;
1 = 0
1 = .25
1 = 1.
int i; ...; i=1; cout << i++; cout << i << endl;
11
1 1
12
int i; ...; i=1; cout << ++i; cout << i << endl;
11
2 1
22
int i,j; ...; cin >> i >> j;
ij.
i and
j
ij.
i j.
cin statement until you
enter two integer values from the keyboard. It stores these in
variables i and j.