Question #14360

How do you write a c# application program that ask three numbers and prints the average value?
NB. the program must have only two console.writeline statements.

Expert's answer

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;




namespace Answer14360

{

class Program

{

static void Main(string[] args)

{

int _count=0;

int _average=0;

do

{

_count++;

Console.WriteLine("Enter {0}-st number ", _count);

_average += Convert.ToInt32(Console.ReadLine());

} while (_count < 3);



Console.WriteLine("Average value={0}",_average/3);

Console.ReadKey();

}

}

}

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!

LATEST TUTORIALS
APPROVED BY CLIENTS