From 16094a5be82eadd209fee8d42b2c81968459d7a2 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka Date: Fri, 19 Nov 2021 10:36:17 +0000 Subject: [PATCH 01/14] added file --- function_sum.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 function_sum.cpp diff --git a/function_sum.cpp b/function_sum.cpp new file mode 100644 index 0000000..e69de29 From 628235f3e696e7756ac10ebe08b0521ed5604708 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka Date: Fri, 19 Nov 2021 10:46:47 +0000 Subject: [PATCH 02/14] added new py file --- function.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 function.py diff --git a/function.py b/function.py new file mode 100644 index 0000000..e69de29 From ba2c162cd45ac023c871f0f387ca465ed0ab9d23 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Tue, 23 Nov 2021 19:54:13 +0200 Subject: [PATCH 03/14] wrote a function --- function_sum.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/function_sum.cpp b/function_sum.cpp index e69de29..9e8a072 100644 --- a/function_sum.cpp +++ b/function_sum.cpp @@ -0,0 +1,7 @@ +#include +int main(x, y) { + int x = 3; + int y = 2; + int sum = x + y; + std::cout << sum ; +} \ No newline at end of file From c0fc2dd0c304fc2c187f580e38a5efbcb51dd426 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Tue, 23 Nov 2021 20:15:42 +0200 Subject: [PATCH 04/14] wrote a function --- function.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/function.py b/function.py index e69de29..fa79ee7 100644 --- a/function.py +++ b/function.py @@ -0,0 +1,6 @@ +def main(): + x = 3 + y = 2 + return x + y + +print(main()) \ No newline at end of file From 2fa9ad4817b5a73dae404303759be29b9d0f9499 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 24 Nov 2021 00:17:09 +0200 Subject: [PATCH 05/14] added cpp and js codes --- function_sum.cpp | 16 ++++++++++------ function_sum.js | 5 +++++ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 function_sum.js diff --git a/function_sum.cpp b/function_sum.cpp index 9e8a072..02da9bb 100644 --- a/function_sum.cpp +++ b/function_sum.cpp @@ -1,7 +1,11 @@ #include -int main(x, y) { - int x = 3; - int y = 2; - int sum = x + y; - std::cout << sum ; -} \ No newline at end of file +using namespace std; + +int sum(int x, int y) { + return x+y; +} + +int main() { + cout << sum(3, 2); + return 0; +} diff --git a/function_sum.js b/function_sum.js new file mode 100644 index 0000000..8bcd042 --- /dev/null +++ b/function_sum.js @@ -0,0 +1,5 @@ +function adding(x, y) { + return x + y; +} +let result = adding(3, 2); +console.log(result); \ No newline at end of file From 6cd9b688d7aedeb6d8691aed952387c52b1a8dd1 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 24 Nov 2021 01:19:31 +0200 Subject: [PATCH 06/14] added loop functions --- def_loop.py | 9 +++++++++ func_loop.js | 10 ++++++++++ func_sum.cpp | 16 ++++++++++++++++ function_sum.cpp | 1 + 4 files changed, 36 insertions(+) create mode 100644 def_loop.py create mode 100644 func_loop.js create mode 100644 func_sum.cpp diff --git a/def_loop.py b/def_loop.py new file mode 100644 index 0000000..6589a9a --- /dev/null +++ b/def_loop.py @@ -0,0 +1,9 @@ +prices = [40,30,50] +def adding(x): + to_pay = 0 + for i in x: + to_pay += i + return to_pay + +print(adding(prices)) + diff --git a/func_loop.js b/func_loop.js new file mode 100644 index 0000000..88fbad2 --- /dev/null +++ b/func_loop.js @@ -0,0 +1,10 @@ +let prices = [40,30,50]; +function adding(x) { + let to_pay = 0; + for (i of x) { + to_pay += i; + } + return to_pay; +} + +console.log(adding(prices)) \ No newline at end of file diff --git a/func_sum.cpp b/func_sum.cpp new file mode 100644 index 0000000..dd3a39e --- /dev/null +++ b/func_sum.cpp @@ -0,0 +1,16 @@ +#include +#include +using namespace std; +using std::cout; +using std::array; + +int prices[] = {40,30,50}; +int adding(int x[]) { + int to_pay = 0; + for (int i = 0; i using namespace std; +using std::cout; int sum(int x, int y) { return x+y; From fb0d669dd04ef4f8bb9fde676cef68f51b910eb1 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 24 Nov 2021 10:00:29 +0200 Subject: [PATCH 07/14] added blank space at the end --- func_loop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/func_loop.js b/func_loop.js index 88fbad2..aa7cb2e 100644 --- a/func_loop.js +++ b/func_loop.js @@ -7,4 +7,4 @@ function adding(x) { return to_pay; } -console.log(adding(prices)) \ No newline at end of file +console.log(adding(prices)) From fc65ad6473afde9fcddec566204b515a10e35abc Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 24 Nov 2021 10:01:42 +0200 Subject: [PATCH 08/14] updated fuction also added blank space --- function.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/function.py b/function.py index fa79ee7..95d9e0b 100644 --- a/function.py +++ b/function.py @@ -1,6 +1,4 @@ -def main(): - x = 3 - y = 2 +def main(x, y): return x + y -print(main()) \ No newline at end of file +print(main(3, 2)) From 8ca726e2c673d2885b833216908605de3a7c6099 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 24 Nov 2021 10:02:08 +0200 Subject: [PATCH 09/14] added bank space --- function_sum.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/function_sum.js b/function_sum.js index 8bcd042..f63f98e 100644 --- a/function_sum.js +++ b/function_sum.js @@ -2,4 +2,4 @@ function adding(x, y) { return x + y; } let result = adding(3, 2); -console.log(result); \ No newline at end of file +console.log(result); From a9bd02578a903cdc5db581ae42197424a285283d Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 24 Nov 2021 10:53:29 +0200 Subject: [PATCH 10/14] corrected cpp file so it works --- func_sum.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/func_sum.cpp b/func_sum.cpp index dd3a39e..461437b 100644 --- a/func_sum.cpp +++ b/func_sum.cpp @@ -1,16 +1,19 @@ #include -#include using namespace std; using std::cout; -using std::array; -int prices[] = {40,30,50}; -int adding(int x[]) { +int prices[] = { 40, 30, 50 }; + +int adding(int x[], int size) { int to_pay = 0; - for (int i = 0; i Date: Wed, 24 Nov 2021 10:00:29 +0200 Subject: [PATCH 11/14] added blank space at the end --- func_loop.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/func_loop.js b/func_loop.js index 88fbad2..aa7cb2e 100644 --- a/func_loop.js +++ b/func_loop.js @@ -7,4 +7,4 @@ function adding(x) { return to_pay; } -console.log(adding(prices)) \ No newline at end of file +console.log(adding(prices)) From fe055ddd4918018ba8c48a085e360aa0e334e6a4 Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 24 Nov 2021 10:01:42 +0200 Subject: [PATCH 12/14] updated fuction also added blank space --- function.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/function.py b/function.py index fa79ee7..95d9e0b 100644 --- a/function.py +++ b/function.py @@ -1,6 +1,4 @@ -def main(): - x = 3 - y = 2 +def main(x, y): return x + y -print(main()) \ No newline at end of file +print(main(3, 2)) From 09f532d05e6caa3aa4b553b276766802063501ee Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 24 Nov 2021 10:02:08 +0200 Subject: [PATCH 13/14] added bank space --- function_sum.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/function_sum.js b/function_sum.js index 8bcd042..f63f98e 100644 --- a/function_sum.js +++ b/function_sum.js @@ -2,4 +2,4 @@ function adding(x, y) { return x + y; } let result = adding(3, 2); -console.log(result); \ No newline at end of file +console.log(result); From 1cd1770214d1711daaad111b81b3270e14cb160b Mon Sep 17 00:00:00 2001 From: Khrystyna Petrynka <90193412+kpetrynka@users.noreply.github.com> Date: Wed, 1 Dec 2021 09:32:58 +0200 Subject: [PATCH 14/14] Update def_loop.py improved code readability --- def_loop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/def_loop.py b/def_loop.py index 6589a9a..594f24c 100644 --- a/def_loop.py +++ b/def_loop.py @@ -1,4 +1,4 @@ -prices = [40,30,50] +prices = [40, 30, 50] def adding(x): to_pay = 0 for i in x: