Write a script that calculates and prints the sum of the integers from 1 to 10. Use a while statement to loop through the calculation and increment statements. The loop should terminate when the value of x becomes 11.

I used ; while loop for it and used if condition within while loop and add break for 1st loop.
code is given bellow understand it.


                          <?php  
                $num = 0;  
                               while ($num+1)  
                                    {  
                                         echo $num . "<br />";  
                                              if ($num==10)  
                                              {  
                                                   break 1;  
                                              }  
                                         $num++;  
                                    }  
                          ?>  

Post a Comment

Give your reviews about this blog. Leave your comments. What do you think about this post?

Comments Guidelines:

1) I love to read comments, but please avoid spam.

2) Like this blog, share your insights, and spread the word.

3) You can use basic HTML/xHTML tags.

4) All comments are DoFollow—please use the section professionally.

5) Kindly mention your name or brand below your comment.

6) Constructive suggestions for improvement are always welcome.


Thanks for visiting Samee Articles.

========================================

Best Regards,

Samee U. Feroz

 
Copyright © 2011-2026. Samee Articles - All Rights Reserved
Proudly powered by Blogger