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
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 ;
}
| 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 |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
