Computer Science, asked by ppawanyadav740, 5 months ago

a JavaScript function to find sum of first 20 even natural numbers.
पहले 20 सम नेचुरल संख्याओं का योग ज्ञात करने के लिए एक जावास्क्रिप्ट फंक्शन लिखें।​

Answers

Answered by islamjaha949
3

Answer:

In the above program, the user is prompted to enter a number.

The parseInt() converts the numeric string value to an integer value.

The for loop is used to find the sum of natural numbers up to the number provided by the user.

The value of sum is 0 initially.

Then, a for loop is used to iterate from i = 1 to 100.

In each iteration, i is added to sum and the value of i is increased by 1.

When i becomes 101, the test condition is false and sum will be equal to 0 + 1 + 2 + ... + 100.

Similar questions