Write a C#program that takes three numbers as input to calculate and print the average.
Variables are defined in the first row. In the next lines, values are assigned to these variables.
In the last line we print the result of processing on the screen.
You can find more similar examples of programming for this programming language in the site.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
class Program { static void Main(string[] args) { int number1,number2,number3,avarage; Console.Write("Enter 1st number :"); number1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter 2nd number :"); number2 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter 3rd number :"); number3 = Convert.ToInt32(Console.ReadLine()); avarage = (number1 + number2 + number3) / 3; Console.Write("Avarage of three numbers is {0}",avarage); Console.ReadKey(); } } |
Output: