Question: // A while loop for sum of first n positive integers. #include using namespace std; int main() { int n, i = 1; cout <

// A while loop for sum of first n positive integers. #include  using namespace std; int main() { int n, i = 1; cout << "Enter a positive integer: "; cin >> n; long sum = 0; while (i <= n) sum += i++; cout << "Sum of first " << n << " positive integers = " << sum << endl; } // What is the value of sum for given n ? 
- a. b. c. d. e. f. g.

n = 10

- a. b. c. d. e. f. g.

n =100

- a. b. c. d. e. f. g.

1000

- a. b. c. d. e. f. g.

1000000

- a. b. c. d. e. f. g.

10000000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!