+ 1
we can add using loops. what if the loop is infinite.for example -
public class Axis { public static void main(String[]args){ int result = 0; for(int i =0;i<10;i--){ result +=i; } System. out. println(result); } } IN THE CODES THE INTEGER I IS DECREMENTED INFINITELY SO WHAT WILL BE THE RESULT. I HAVE TRIED IT IN COMPUTERS AND EVEN GOT SOME NUMBERS.but Hoooooow.plz explain
1 Answer
+ 12
The infinite loop is stopped after a while (because of memory overflow or exceeded time limit). But the program doesn't crash so the result will be output.