0% found this document useful (0 votes)
14 views

Activity 4

The document describes an activity that generates a random array of integers, copies the values to a new array in reverse order, and prints both arrays. It uses random numbers, loops, and arrays.

Uploaded by

Kevin Cáceres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Activity 4

The document describes an activity that generates a random array of integers, copies the values to a new array in reverse order, and prints both arrays. It uses random numbers, loops, and arrays.

Uploaded by

Kevin Cáceres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Activities
{
internal class Activity4
{
public void Start()
{
Random random = new Random();
int arraySize = random.Next(1, 50);
int[] intArray = new int[arraySize];

// Fill array with random numbers


for (int i = 0; i < intArray.Length; i++)
{
intArray[i] = random.Next(1, 25);
}

// Copy values except for the one to remove


int[] modArray = new int[intArray.Length];
int j = 0;
for (int i = intArray.Length - 1; i >= 0; i--)
{
modArray[j] = intArray[i];
j++;
}

// Print original array


foreach (int val in intArray)
{
Console.Write("{0}, ", val);
}
Console.WriteLine();

// Print modified array


foreach (int val in modArray)
{
Console.Write("{0}, ", val);
}
Console.WriteLine();
}
}
}

You might also like