using System;
class Average5
{
public static void Main()
{
int number1,number2,number3,number4,number5,avg,sum;
Console.WriteLine("Enter 5 Numbers:");
number1=Convert.ToInt32(Console.ReadLine());
number2=Convert.ToInt32(Console.ReadLine());
number3=Convert.ToInt32(Console.ReadLine());
number4=Convert.ToInt32(Console.ReadLine());
number5=Convert.ToInt32(Console.ReadLine());
sum=(number1+number2+number3+number4+number5);
avg=(sum/5);
Console.WriteLine("The Sum Is:"+sum);
Console.WriteLine("The Average Is:"+avg);
}
}
OUTPUT:-class Average5
{
public static void Main()
{
int number1,number2,number3,number4,number5,avg,sum;
Console.WriteLine("Enter 5 Numbers:");
number1=Convert.ToInt32(Console.ReadLine());
number2=Convert.ToInt32(Console.ReadLine());
number3=Convert.ToInt32(Console.ReadLine());
number4=Convert.ToInt32(Console.ReadLine());
number5=Convert.ToInt32(Console.ReadLine());
sum=(number1+number2+number3+number4+number5);
avg=(sum/5);
Console.WriteLine("The Sum Is:"+sum);
Console.WriteLine("The Average Is:"+avg);
}
}
4 comments:
you can also do it by this code , via for loop .. to reduce the code line :
using System;
class Program
{
static void Main()
{
int sum = 0;
for(int i=0; i<5; i++)
{
Console.WriteLine("Enter the Integers");
sum = sum + Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("sum = {0}", sum);
Console.WriteLine("Average = {0}", sum/5);
Console.ReadLine();
}
}
Useful information.I am actual blessed to read this article.thanks for giving us this advantageous information.I acknowledge this post.and I would like bookmark this post.Thanks
python Training in Pune
python Training in Chennai
python Training in Bangalore
Thanks for sharing The Information The Information shared is very valuable Please keep Updating us Time Just went on redaing the article Python Online Training AWS Online Training Devops Online Training Data Science Online Training
Post a Comment