how do you write a C# console application program that asks for three numbers and prints the average value?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace three_numbers_and_prints_the_average_value
{
class Program
{
static void Main(string[] args)
{
double sum = 0;//variable for sum of three number
for(int i=0;i<3;i++){
Console.Write("Enter number # " + (i + 1).ToString()+": ");
sum += double.Parse(Console.ReadLine());//read number
}
Console.Write("The average value is: "+(sum/3).ToString());//show
result
Console.ReadLine();//delay
}
}
}
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!
Learn more about our help with Assignments:
C#