63 064
Assignments Done
99,1%
Successfully Done
In July 2018

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);

}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions