+ Start a Discussion
lonely boylonely boy 

Print numbers 1 to 100 by skipping 40 to 60.How can I achieve this?

ANUTEJANUTEJ (Salesforce Developers) 
Hi there, 

You can try below code once:

for(integer i=1;i<=100;i++)
if(i>=40 && i<=60)
{ system.debug(i);}

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

You may use below code:

for(integer i=1;i<=100;i++) {
    if(i<40 || i>60){ 
Sachin HoodaSachin Hooda
Integer i = 0; 
while(i < 100){ 
     if(i == 41) i+=20;
This would work too!