Foros aprenderaprogramar.com

Aprender a programar => C, C++, C#, Java, Visual Basic, HTML, PHP, CSS, Javascript, Ajax, Joomla, MySql y más => Mensaje iniciado por: Gabrield Marquez en 05 de Enero 2016, 00:08

Título: C# pedir números al usuario por consola Console.ReadLine() y calcular promedio
Publicado por: Gabrield Marquez en 05 de Enero 2016, 00:08
Código del ejemplo:

Código: [Seleccionar]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
           

int sum = 0; int numero1 = 0; int numero2 = 0; int numero3 = 0; int numero4 = 0; int numero5 = 0; int promedio = 0;

 Console.WriteLine("Primer Numero");
 numero1 = Int32.Parse(Console.ReadLine());

Console.WriteLine("Segundo Numero");
 numero2 = Int32.Parse(Console.ReadLine());

Console.WriteLine("Tercer Numero");
 numero3 = Int32.Parse(Console.ReadLine());

Console.WriteLine("Cuarto Numero");
 numero4 = Int32.Parse(Console.ReadLine());

Console.WriteLine("Quinto Numero");
 numero5 = Int32.Parse(Console.ReadLine());

sum = numero1 + numero2 + numero3 + numero4 + numero5;
promedio = sum / 5;
                Console.WriteLine("El Promedio es  {0}", promedio);
                Console.ReadKey();
        }
    }
}