16
int price, profit; for (price = 10; price <= 30; price +=1) { profit = price * (100 – 3 * price); cout << setw(5) << price << setw(10) << profit << endl; }

int price, profit; for (price = 10; price

Embed Size (px)

DESCRIPTION

int price, profit; for (price = 10; price

Citation preview

Page 1: int price,     profit; for (price = 10; price

int price,

profit;

for (price = 10; price <= 30; price +=1)

{

profit = price * (100 – 3 * price);

cout << setw(5) << price << setw(10)

<< profit << endl;

}

Page 2: int price,     profit; for (price = 10; price

int i;

for (i = 10; i >= 0; i = i – 2)

cout << i << ‘ ‘;

Page 3: int price,     profit; for (price = 10; price

char ltr;

for (ltr = ‘A’; ltr <= ‘F’; ltr++)

cout << ltr;

Page 4: int price,     profit; for (price = 10; price

int i;

for (i = 1; i <= 10; ++i)

cout << i << “ “;

Page 5: int price,     profit; for (price = 10; price

int i;

for (i = 5; i > 0; ++i)

cout << i << “ “;

Page 6: int price,     profit; for (price = 10; price

int i;

for (i = 1; i <= 10; ++i)

{

cout << i << “ “;

i += 2;

}

Page 7: int price,     profit; for (price = 10; price

int i,

num,

sum = 0;

for (i = 0; i <= 4; i++)

{

cout << “Enter number #” << (i + 1) << ‘ ‘;

cin >> num;

sum += num;

}

Page 8: int price,     profit; for (price = 10; price

int i;

for (i = 1; i <=3; i++)

cout << “Hi “;

cout << “there. \n”;

cout << “Bye\n”;

Page 9: int price,     profit; for (price = 10; price

int j;

for (j = 20; j >= 5; j -= 3)

cout << j << ‘ ‘;

Page 10: int price,     profit; for (price = 10; price

int j;

for (j = 20; j >= 5; j += 7)

cout << j << ‘ ‘;

Page 11: int price,     profit; for (price = 10; price

int sum = 0,

j;

for (j = 1; j <= 4; j++)

{

sum += j * j;

cout << j << ‘ ‘ << sum << endl;

}

cout << “done\n”;

Page 12: int price,     profit; for (price = 10; price

Fill in the blanks:output: 2 3 5 8 13 21 34 55int i, sum, j = 1, k = 1;for (i = 1; i <= 8; i++) { __________ = j + k; cout << sum << ‘ ‘; j = k; k = _____; }

Page 13: int price,     profit; for (price = 10; price

Fill in the blanks:output: 2^1 = 2 2^2 = 4 2^3 = 8 2^4 = 16 2^5 = 32 2^6 = 64int j, prod = 1;for (j = 1; _______; ++j) { prod = ______; cout << “2^” << ___ << “ = “ << ____ << endl; }

Page 14: int price,     profit; for (price = 10; price

int j,

p = 30;

for (j = 5; j; --j)

{

p -= 2;

cout << p << ‘ ‘;

if (p % 4)

cout << “OK”;

cout << ‘\n’;

}

Page 15: int price,     profit; for (price = 10; price

int j, m = 10, p = 20;for (j = 1; j <= 3; j++) { p = m – 2; m = m + p; p += 6; if (m > p) cout << p; else cout << m; cout << endl; }cout << m << ‘ ‘ << p;

Page 16: int price,     profit; for (price = 10; price

int row,

col;

for (row = 1; row < 6; row++)

{

for (col = 1; col < 11; col++)

cout << row << ‘,’ << col << ’\t”;

cout << endl;

}