Write a program in c# that will accept 10 numbers. The program will then compute and display the sum of the odd and even numbers
using System;
public class Exercise4
{
public static void Main()
{
int i,n,sum=0;
double avg;
Console.Write("\n\n");
Console.Write("Read 10 numbers and calculate sum and average:\n");
Console.Write("----------------------------------------------");
Console.Write("\n\n");
Console.Write("Input the 10 numbers : \n");
for (i=1;i<=10;i++)
{
Console.Write("Number-{0} :",i);
n= Convert.ToInt32(Console.ReadLine());
sum +=n;
}
avg=sum/10.0;
Console.Write("The sum of 10 no is : {0}\nThe Average is : {1}\n",sum,avg);
}
}
Comments
Leave a comment