Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TareaConsola01
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("*****Mi primer Programa en C#*****"); //mostrar mensaje
- CapturarNombre(); ///llama al metodo CapturarNombre
- ImprimirCiclo(); //metodo que inicia ciclo iterativo
- Console.Write("El resultado es "+DevolverSuma()+"\n"); //funcion que devuelve el resultado de la suma
- Console.Write("\n*****Fin de la Aplicacion*****\n"); //Cierre de la aplicacion
- Console.ReadKey();
- }
- /// <summary>
- /// Captura un dato de tipo string
- /// </summary>
- public static void CapturarNombre()
- {
- Console.Write("\nIngrese su nombre: \n");
- string nombre = Console.ReadLine();
- Console.WriteLine("Tu nombre es: " + nombre);
- Console.ReadKey();
- }
- /// <summary>
- /// Inicia un ciclo iterativo
- /// </summary>
- public static void ImprimirCiclo(){
- Console.Write("\n*****Ciclo Iterativo*****\n");
- int i = 0;
- for (i = 0; i < 10; i++)
- {
- {
- Console.WriteLine("\tnumero " + (i + 1));
- }
- }
- Console.Write("*****Fin Ciclo Iterativo*****\n");
- Console.ReadKey();
- }
- /// <summary>
- /// funcion que suma dos enteros
- /// </summary>
- /// <returns></returns>
- public static int DevolverSuma()
- {
- Console.Write("\n*****Suma de dos numeros*****\n");
- Console.Write("\ningrese un numero: \n");
- int numero1 = int.Parse(Console.ReadLine());
- Console.Write("ingrese otro numero: \n");
- int numero2 = int.Parse(Console.ReadLine());
- return numero1 + numero2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment