Answer to Question #34172 in C# for Nkosinathi

Question #34172
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

}
}
}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS