1.09: Average
OBJECTIVE
Write a C# program to calculate and display the average of four numbers entered by the user.
RESOLUTION
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace My3Development { public class Average { public static void Main(String[] args) { int num1,num2,num3,num4; Console.Write("Enter the First number\t: "); num1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the Second number\t: "); num2 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the third number\t: "); num3 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the four number\t: "); num4 = Convert.ToInt32(Console.ReadLine()); int result = (num1 + num2 + num3 + num4) / 4; Console.WriteLine("the average of {0} , {1} , {2} , {3} is: {4} ", num1, num2, num3, num4, result); Console.ReadKey(); } } }
0 comments :
Please Enter best of your Comments