Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In a bowling game, there are a total of ten pins arranged in four rows, like thi

ID: 3538153 • Letter: I

Question

In a bowling game, there are a total of ten pins arranged in four rows, like this:

   *

**

***

****

Note that there's one pin in the first row, two in the second and so on.

Now, suppose that there's a strange alien civilization where they bowl using 8,359 rows of pins. Furthermore, their pins are arranged with one pin in the first row, three in the second and so on.


      *

   * * *

* * * * *

Write a program that uses a while loop to compute and display how many total pins there would be in such a game.

Explanation / Answer

General function:

int sumPins(int rows)

{

int count, pins = 0;


while(count < rows)

{

pins += 2*count + 1;

count++;

}

return pins;

}


Now you need to just use the function/method in the main method of a program. This function should work for most languages.