Ask your own question, for FREE!
Mathematics 9 Online
OpenStudy (anonymous):

Wrte a for loop to compute the sum 1 + 2 + 3 + 4 Multiple answers. Answer A int sum =0; for (int j = 0 ; j < 4 ; j++) sum=sum+j; B int sum =0; for (int j = 1; j < 5 ; j++) sum=sum+j; C int sum =0; for (int j = 1 ; j < 6 ; j++) sum=sum+j; D int sum =0; for (int j = 1 ; j <= 4 ; j++) sum += j;

OpenStudy (kinggeorge):

From what I can see, both B and D would work.

OpenStudy (kinggeorge):

After testing both methods, both B and D do indeed work.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!