Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- const int SIZE = 50;
- int[] array = new int[SIZE];
- int index = 0;
- int aScore = 0;
- do
- {
- Console.WriteLine("Enter a value for the array for position {0} (or 0 to stop):", (index + 1));
- aScore = int.Parse(Console.ReadLine());
- if(aScore >= 0)
- {
- array[index++] = aScore;
- }
- }while (aScore != 0 && index < SIZE);
- Console.WriteLine("The product of the array is: {0}", SumArray(array));
- Console.ReadLine();
- }
- static int SumArray(int[] array)
- {
- int product = 1;
- for (int i = 0; i < array.Length; i++)
- {
- product *= array[i];
- }
- return product;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement