Use block inside for statement : For : Statement C# Examples


C# Examples » Statement » For »

 

Use block inside for statement









    
using  System;    
      
class  MainClass  {      
    public  static  void  Main()  {      
        int  prod;  
        int  sum;  
        int  i;  
  
        sum  =  0;  
        prod  =  1;  
  
        for(i=1;  i  <=  10;  i++)  {  
            sum  =  sum  +  i;  
            prod  =  prod  *  i;              
        }  
        Console.WriteLine("Sum  is  "  +  sum);  
        Console.WriteLine("Product  is  "  +  prod);  
  
    }      
}
    
   
  
   



Output

Sum is 55
Product is 3628800


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» For