find the sum of a 5 number list in c++ in javascript
Here's how you can find the sum of a 5 number list in C++:
#include<iostream>usingnamespacestd;
intmain(){
int numbers[5] = {1, 2, 3, 4, 5};
int sum = 0;
for(int i = 0; i < 5; i++){
sum += numbers[i];
}
cout<<"The sum of the numbers is: "<<sum<<endl;
return0;
}
233 chars
13 lines
And here's how you can find the sum of a 5 number list in JavaScript:
index.tsx
let numbers = [1, 2, 3, 4, 5];
let sum = 0;
for(let i = 0; i < numbers.length; i++){
sum += numbers[i];
}
console.log("The sum of the numbers is: "+sum);