Interview Questions

Detemine the code below, tell me exectly how many times is the operation sum++ performed ?

C++ programming on UNIX, C++ Networking,C++ Algorithm Questions and Answers


(Continued from previous question...)

Detemine the code below, tell me exectly how many times is the operation sum++ performed ?

for ( i = 0; i < 100; i++ )
for ( j = 100; j > 100 - i; j–)
sum++;

(99 * 100)/2 = 4950
The sum++ is performed 4950 times.

(Continued on next question...)

Other Interview Questions