how do you write a C# console application program that asks for three numbers and prints the average value?
1
Expert's answer
2013-08-15T07:37:20-0400
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
Comments
Leave a comment