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

Whart difference between these two questions . Give me the exxplanation. 1. What

ID: 3866767 • Letter: W

Question

Whart difference between these two questions. Give me the exxplanation.

1. What are the values of i and sum after this code sequence is executed? i is 40
sum is 60

int i = 0;
int sum = 0;
for ( i = 0; i < 40; i++)

{

if ( i % 10 = = 0)

sum += i ;

}

2. What are the values of i and sum after this code sequence is executed?

int i = 0;
int sum = 0;
for ( i = 0; i < = 40; i++)
{

if ( i % 10 = = 0)

sum += i ;

}

i is 40
sum is 60

i is 41
sum is 60

i is 40
sum is 100

i is 41
sum is 100

a.

i is 40
sum is 60

b.

i is 41
sum is 60

c.

i is 40
sum is 100

d.

i is 41
sum is 100

Explanation / Answer

1) For the First one the output after the code execution will be

I = 39

Sum = 60.

2) For the second one the output would be

I= 40

Sum = 100.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote