#Day3 'C' Coding Challenge

#Day3 'C' Coding Challenge

 

Predict the correct answer for the above code snippet.
A) 17
B) 15
C) 13
D) 10

The above code snippet is to test the loop statements and conditional checks knowledge.

The for loop checks below:

For i = 0, i < 5, as i==3 is not satisfied, result = result + 0 => result = 0
For i = 1, i < 5, as i==3 is not satisfied, result = result + 1 => result = 1 
For i = 2, i < 5, as i==3 is not satisfied, result = result + 2 => result = 3 
For i = 3, i < 5, as i==3 is satisfied, result = result + 10 => result = 13 
For i = 4, i < 5, as i==3 is not satisfied, result = result + 4 => result = 17 
For i = 5, i < 5, for loop is exited

The result 17 is resulted.

Post a Comment

0 Comments