# Answer to Question #16798 in C# for paul uy

Question #16798

input N integers (ask from the user how many numbers he/she wants to input) determine and print the sum of all numbers, the average of all numbers, how many odd numbers were inputted, how many even numbers were entered and how many zeroes inputted

Expert's answer

using System;

using System.Collections.Generic;

using

System.Linq;

using System.Text;

namespace

ConsoleApplication1

{

class Program

{

static void

Main(string[] args)

{

int n = 0;

Console.WriteLine("Input N: ");

n =

int.Parse(Console.ReadLine());

int[] num = new

int[n];

int sum = 0;

int even = 0;

int odd = 0;

int zeroes = 0;

for (int i = 0; i

< n; i++)

{

Console.WriteLine("Input new

integer: ");

num[i] =

int.Parse(Console.ReadLine());

sum = sum +

num[i];

if (num[i] % 2 == 0)

{

even++;

}

else

{

odd++;

}

if (num[i] == 0)

{

zeroes++;

}

}

int ave = sum / n;

Console.WriteLine("Sum: " +

sum);

Console.WriteLine("Average: " + ave);

Console.WriteLine("Odds: " + odd);

Console.WriteLine("Evens: " +

even);

Console.WriteLine("Zeroes: " + zeroes);

}

}

}

using System.Collections.Generic;

using

System.Linq;

using System.Text;

namespace

ConsoleApplication1

{

class Program

{

static void

Main(string[] args)

{

int n = 0;

Console.WriteLine("Input N: ");

n =

int.Parse(Console.ReadLine());

int[] num = new

int[n];

int sum = 0;

int even = 0;

int odd = 0;

int zeroes = 0;

for (int i = 0; i

< n; i++)

{

Console.WriteLine("Input new

integer: ");

num[i] =

int.Parse(Console.ReadLine());

sum = sum +

num[i];

if (num[i] % 2 == 0)

{

even++;

}

else

{

odd++;

}

if (num[i] == 0)

{

zeroes++;

}

}

int ave = sum / n;

Console.WriteLine("Sum: " +

sum);

Console.WriteLine("Average: " + ave);

Console.WriteLine("Odds: " + odd);

Console.WriteLine("Evens: " +

even);

Console.WriteLine("Zeroes: " + zeroes);

}

}

}

## Comments

## Leave a comment