logo image

C# program to print average of given 3 numbers

Views: 18

Following program shows you how to print average of given 3 numbers. In this program we get inputs from user and calculate average of given 3 numbers using following formula Average of given 3 numbers = (input1 + input2 + input3) / 3

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine ("Enter first number:");
    int input1 = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine ("Enter second number:");
    int input2 = Convert.ToInt32(Console.ReadLine());
    Console.WriteLine ("Enter third number:");
    int input3 = Convert.ToInt32(Console.ReadLine());
    int result = (input1 + input2 + input3) / 3;
    Console.WriteLine("The average of three numbers: " + result);


Enter first number:
Enter second number:
Enter third number:
The average of three numbers: 15
We are looking for Interns!
Send your resumes to
[email protected]