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:32

Título: C# pedir números al usuario Int32.Parse(Console.ReadLine()) y contar positivos
Publicado por: Gabrield Marquez en 05 de Enero 2016, 00:32
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 positivos = 0; int conta = 0; int numero;
            Console.WriteLine("Introduce Numero");
            numero = Int32.Parse(Console.ReadLine());
            while (numero != 999) {
                conta = conta + 1;
                if (numero > 0) positivos = positivos + 1;
                Console.WriteLine("Introduce numero");
                numero = Int32.Parse(Console.ReadLine());
            }
            Console.WriteLine("Has introducido un total de {0}", conta);
            Console.WriteLine("y son positivos {0}", positivos);
           
           
        }//fin Main
    }
}