diff options
Added practice from the 8th of October
1 files changed, 82 insertions, 0 deletions
| -rw-r--r-- | Year 1/Programming introduction/Practice-08.10.21.cpp | 82 |
diff --git a/Year 1/Programming introduction/Practice-08.10.21.cpp b/Year 1/Programming introduction/Practice-08.10.21.cpp new file mode 100644 index 0000000..25f5c9a --- /dev/null +++ b/Year 1/Programming introduction/Practice-08.10.21.cpp @@ -0,0 +1,82 @@ +#include <iostream> + +using namespace std; + +void ex1() { + int a; + cin >> a; + cout << (bool)a; +} + +void ex2() { + int a; + cin >> a; + cout << "Square: " << a * a << " " << a * 4 << endl; + cout << "Circle: " << 3.14 * a * 2 << endl; + cout << "Triangle: " << 1.73 * a * a / 4 << " " << a * 3; +} + +void ex3() { + int a; + cin >> a; + cout << !(a % 2); +} + +void ex4() { + int A, B, a, b, temp; + cin >> a >> b; + A = a, B = b; + + a += b; + b = a - b; + a -= b; + cout << a << " " << b << endl; + a = A, b = B; + + a *= b; + b = a / b; + a /= b; + cout << a << " " << b << endl; + a = A, b = B; + + temp = a; + a = b; + b = temp; + cout << a << " " << b << endl; +} + +void ex5() { + char letter; + cin >> letter; + cout << (letter == 'a' || letter == 'i' || letter == 'u' || letter == 'e' || letter == 'o'); // when is vowel +} + +void ex6() { + int a; + cin >> a; + cout << a % 10 << (a % 100) / 10 << (a % 1000) / 100 << (a % 10000) / 1000; // 1234 becomes 4321 +} + +void ex7() { + int currQuantity; + double currPrice, aPrice, oPrice, bPrice; + + cout << "Apples: "; + cin >> currQuantity >> currPrice; + aPrice = currQuantity * currPrice; + + cout << "Oranges: "; + cin >> currQuantity >> currPrice; + oPrice = currQuantity * currPrice; + + cout << "Bananas: "; + cin >> currQuantity >> currPrice; + bPrice = currQuantity * currPrice; + + cout << "Your order is: apples for " << aPrice << ", oranges for " << oPrice << " and bananas for " << bPrice << endl; + cout << "Total: " << aPrice + oPrice + bPrice; +} + +int main() { + ex7(); +} |
