Answers:
The problem is that you think that j = 25 when it comes to the if statement.
Unfortunately, the value of j is the following:
[3 5 7 9 11 13 15 17 19 21 ...]
That is, j is a vector! It can never be equal to 25!
The problem would have been solved if you had computed j once using j = 1+2*i.
You should check each step and find out whether it is correct. This can be done in Scilab, as it is an interpreted code.
By the way, your code will not work (will not even go into the infinite loop), as j is not initalised.
with i=o:12
output is [1 3 5...23 25] but not coming out of the loop continue to display
How to come out , working on that ,please check if one can help
Since you had defined i=0:12, the output is displaying an infinite loop. I have made the required changes in your code:
i=0;
j=0;
while (j<=35)
j=1+2*i;
disp(j)
i=i+1;
if (j==25)
then
break
end
end
j=0;
while (j<=35)
j=1+2*i;
disp(j)
i=i+1;
if (j==25)
then
break
end
end
Yes!!
its working!! great,thanks a lot sir!!
I understood, because of i=0:12,'J' was also a vector and could not check break and come out of loop.
Login to add comment
Login to add comment