Skip to content

Commit fd66552

Browse files
committed
feat: sum exercise added
1 parent f8f4676 commit fd66552

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

exercises/sum.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
/*
2-
Write a program that takes as input two numbers and print the sum.
1+
/* Reminder -- Gli studenti della Steve Jobs non potranno scrivere in C++
2+
quindi scriveremo in linguaggio JavaScript */
33

4-
Output:
5-
Insert the first number: 1
6-
Insert the second number: 2
7-
Sum: 3
8-
*/
4+
const readline = require('readline');
5+
6+
const rl = readline.createInterface({
7+
input: process.stdin,
8+
output: process.stdout
9+
});
10+
11+
rl.question('Insert the first number: ', (num1) => {
12+
rl.question('Insert the second number: ', (num2) => {
13+
const result = num1 + num2;
14+
console.log("Sum: " + result);
15+
rl.close();
16+
});
17+
});

0 commit comments

Comments
 (0)