Answer:
The program in C# is as follows:
using System;
class Prog {
static void Main() {
int n;
Console.WriteLine("Number of integers: ");
n = Convert.ToInt32(Console.ReadLine());
int evensum = 0, oddsum = 0; int inpt;
for(int i = 0;i<n;i++){
inpt = Convert.ToInt32(Console.ReadLine());
if(inpt%2==0){ evensum+=inpt; }
else{ oddsum+=inpt; }
}
Console.WriteLine(evensum);
Console.WriteLine(oddsum);
}
}
Explanation:
This declares n, the number of integer inputs
int n;
This prompts for n
Console.WriteLine("Number of integers: ");
This gets input for n
n = Convert.ToInt32(Console.ReadLine());
This declares and initializes the even and odd sum.
int evensum = 0, oddsum = 0; int inpt;
This iterates through n
for(int i = 0;i<n;i++){
This gets each input
inpt = Convert.ToInt32(Console.ReadLine());
Check for even numbers and add,if even
<em> if(inpt%2==0){ evensum+=inpt; }</em>
Otherwise, add input as odd
<em> else{ oddsum+=inpt; }</em>
}
Print even sum
Console.WriteLine(evensum);
Print odd sum
Console.WriteLine(oddsum);
}