Answer to Question #14360 in C# for Bongani
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.
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();
}
}
}
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 orderand get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments
You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!
wow it working thanks a lot
Leave a comment