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
1
Expert's answer
2012-10-22T07:41:03-0400
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);
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Great service! I had an assignment theory to be done and wasn't specific enough from my side on what I exactly needed it for. Even after messaging the expert one day before, they had it done the next day by the time I requested last minute.
Comments
Leave a comment