1.

Answer this question correctly to get 25 points and extra points later as a reward. Give the output of the following program segment. Also mention the number of times the loop is executed: int a,b=4; for(a=6,a

Answer»

is 12. Twice.In the loop : for (a = 6, b=4; a< =24; a = a+6), the value of a will be incrementing as 6, 24 and upon incrementing the value to 42, the loop will terminate.Accordingly the loop has to execute two times.But WITHIN the loop there is a condition : if(a%b = =0) break;This means when REMAINDER on dividing a by b COMES out to be 0 (at 24/4 = 0), the condition breaks and from the above it is clear that value of a is INCREMENTED from 6 to 24 when the loop executes second time.



Discussion

No Comment Found