Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit84402549c630e09ec80ddd04f9886d11d2e75902 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-12 09:46:13 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-10-12 09:46:13 +0300
Files13e7007493e82be98d5f390d187b9b4f5c3a0587
uni-projects-84402549c630e09ec80ddd04f9886d11d2e75902.tar
uni-projects-84402549c630e09ec80ddd04f9886d11d2e75902.tar.gz
uni-projects-84402549c630e09ec80ddd04f9886d11d2e75902.zip
Parenteac2a75365fcea050e40d7219c91bcde1acfdc32 (diff)
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.cpp82
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();
+}