observe the following coding and find how many times "I am very very sorry" displayed??
int k=10;
for(int i=0;i<k--;i++)
System.out.println("I am very very sorry");
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
value of i is increasing (i++) while value of k is decreasing (k-- in condition)...Values are as under s.no. i k 1 0 9(k--) 2 1 8 3 2 7 4 3 6 5 4 5 6 5 6 (this violates the condition i<k--) hence the statement is printed 5 times.