GoConqr has a new look! Let us know what you think.

Module 9 of 9 · Text

Ejercicios de Arrays

Anthony Anthony

//EJERCICIO 1

namespace Proyecto
{
    internal class Program
    {
        static void Main(string[] args)
        {
            // Paso 1: Crear un array con los números del 1 al 10
            int[] numeros = new int[10];
            for (int i = 0; i < 10; i++)
            {
                numeros[i] = i + 1;
            }

            // Paso 2: Crear un array donde almacenar los números pares
            // Usamos LINQ para filtrar los números pares
            int[] numerosPares = numeros.Where(n => n % 2 == 0).ToArray();

            // Paso 3: Mostrar los resultados
            Console.WriteLine("Números del 1 al 10:");
            foreach (var num in numeros)
            {
                Console.Write(num + " ");
            }

            Console.WriteLine("\nNúmeros pares:");
            foreach (var num in numerosPares)
            {
                Console.Write(num + " ");
            }

 

 

 

///EJERCICIO 3

 Console.WriteLine("Cuántos clientes desea registrar");
 int clientes = int.Parse(Console.ReadLine());

 string[] nombres = new string[clientes];
 int[] edad = new int[clientes];

 for (int i = 0; i < clientes; i++)
 {
     Console.WriteLine($"Ingrese el nombre del cliente {i+1}: ");
     nombres[i] = Console.ReadLine();

     Console.WriteLine($"Ingresa la edad del cliente {nombres[i]}: ");
     edad[i] = int.Parse(Console.ReadLine());
 }

 for (int i = 0; i < clientes; i++)
 {
     Console.WriteLine($"El nombre del cliente es {nombres[i]} y tiene {edad[i]} años");
 }

        }
    }
    }

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?