160 likes | 275 Views
int price, profit; for (price = 10; price <= 30; price +=1) { profit = price * (100 – 3 * price); cout << setw(5) << price << setw(10) << profit << endl; }. int i; for (i = 10; i >= 0; i = i – 2) cout << i << ‘ ‘;. char ltr; for (ltr = ‘A’; ltr <= ‘F’; ltr++)
E N D
int price, profit; for (price = 10; price <= 30; price +=1) { profit = price * (100 – 3 * price); cout << setw(5) << price << setw(10) << profit << endl; }
int i; for (i = 10; i >= 0; i = i – 2) cout << i << ‘ ‘;
char ltr; for (ltr = ‘A’; ltr <= ‘F’; ltr++) cout << ltr;
int i; for (i = 1; i <= 10; ++i) cout << i << “ “;
int i; for (i = 5; i > 0; ++i) cout << i << “ “;
int i; for (i = 1; i <= 10; ++i) { cout << i << “ “; i += 2; }
int i, num, sum = 0; for (i = 0; i <= 4; i++) { cout << “Enter number #” << (i + 1) << ‘ ‘; cin >> num; sum += num; }
int i; for (i = 1; i <=3; i++) cout << “Hi “; cout << “there. \n”; cout << “Bye\n”;
int j; for (j = 20; j >= 5; j -= 3) cout << j << ‘ ‘;
int j; for (j = 20; j >= 5; j += 7) cout << j << ‘ ‘;
int sum = 0, j; for (j = 1; j <= 4; j++) { sum += j * j; cout << j << ‘ ‘ << sum << endl; } cout << “done\n”;
Fill in the blanks: output: 2 3 5 8 13 21 34 55 int i, sum, j = 1, k = 1; for (i = 1; i <= 8; i++) { __________ = j + k; cout << sum << ‘ ‘; j = k; k = _____; }
Fill in the blanks: output: 2^1 = 2 2^2 = 4 2^3 = 8 2^4 = 16 2^5 = 32 2^6 = 64 int j, prod = 1; for (j = 1; _______; ++j) { prod = ______; cout << “2^” << ___ << “ = “ << ____ << endl; }
int j, p = 30; for (j = 5; j; --j) { p -= 2; cout << p << ‘ ‘; if (p % 4) cout << “OK”; cout << ‘\n’; }
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;
int row, col; for (row = 1; row < 6; row++) { for (col = 1; col < 11; col++) cout << row << ‘,’ << col << ’\t”; cout << endl; }