C# Program:Calculate The Product Of 5 Numbers Entered By User.It Should Use Only One Variable To Accept 5 Numbers.Using For Loop

Sunday, 12 February 2012
using System;
class Break
{
      public static void Main()
     {
             int incr,sum,num;
             Console.WriteLine("Enter 5 Numbers:");
             for(sum=1,num=incr=0;incr<5;incr++)
            {
                   num=Convert.ToInt32(Console.ReadLine());
                   if(num<=0)
                   continue;
                   sum=sum*num;
            }
            Console.WriteLine("The Product of Above numbers is:{0}",sum);
      }
}


1 comments:

  1. need help. [v.n.kulkarni@gmail.com]

Post a Comment