Skip to content
9 changes: 9 additions & 0 deletions def_loop.py
Original file line number Diff line number Diff line change
@@ -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))

10 changes: 10 additions & 0 deletions func_loop.js
Original file line number Diff line number Diff line change
@@ -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))
19 changes: 19 additions & 0 deletions func_sum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
using namespace std;
using std::cout;

int prices[] = { 40, 30, 50 };

int adding(int x[], int size) {
int to_pay = 0;
for (int i = 0; i < size; i++) {
to_pay += x[i];
}
return to_pay;
}

int main() {
int result = adding(prices, sizeof(prices));
cout << result;
return 0;
}
4 changes: 4 additions & 0 deletions function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def main(x, y):
return x + y

print(main(3, 2))
12 changes: 12 additions & 0 deletions function_sum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<iostream>
using namespace std;
using std::cout;

int sum(int x, int y) {
return x+y;
}

int main() {
cout << sum(3, 2);
return 0;
}
5 changes: 5 additions & 0 deletions function_sum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function adding(x, y) {
return x + y;
}
let result = adding(3, 2);
console.log(result);