Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***In C#*** Instructions (20 points) : Please complete the following problem. Please add comments to your program. Write a program that has a array of

***In C#***

Instructions (20 points):

  • Please complete the following problem.
  • Please add comments to your program.

Write a program that has a array of characters and that deletes all repeated letters from the array. When a letter is deleted, the remaining letters are moved forward to fill in the gap. This will create empty positions at the end of the array so that less of the array is used. For example, consider the following code:

  • a[10];
  • a[0] = 'a';
  • a[1] = 'b';
  • a[2] = 'a';
  • a[3] = 'c';

(You can use numbers as values if that is easier for you)

After this code is executed, the value of a[0] is 'a', the value of a[1] is 'b', the value of a[2] is 'c'. (The value of a[3] is no longer of any concern, since the partially filled array no longer uses this indexed variable.) Your code should print out the new values in the array when finished to show there are no longer any duplicate values.

This is what I have so far, but I'm not having any luck completing the code visual studios:

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

namespace Arrays { class Program { static void Main(string[] args) { Int main[]; { //Variable to hold the total number of characters that can be stored into the array Int count;

Console.WriteLine(Please enter the number of characters to be added to the array);

Console.ReadLine count; //Create a character array of the size count Char inputArray[count]; Console.WriteLine(Enter 10 characters of the input array below the other); //Accept the characters as input from the console (int i = 0, i count, ++i) Console.WriteLine inputArray[i] ; //Display the unsorted array Console.WriteLine Unsorted Array for (int i = 0, i count, ++i) Console.WrieLine inputArray[i], ; //Compare every character with all the other characters of the Array //if the characters dont match, just keep moving on to the next character //in the array by the statement ++j for (int i = 0, i count, ++) { //For every element in i, compare elements from i+1 location to count int j = i + 1; while (j count) { If(inputArray[i] == input Array[j]) { for (int k = j, k count - 1, ++k) inputArray[k] = inputArray[k + 1]; count; } else ++j; } } //Display the sorted array Console.WriteLine (Sorted Array); for (int i = 0, i count, ++i) Console.WriteLIne inputArray[i], ; return 0; }

} }

Please remember this **C#**, and not C++. *This also needs to run in Visual Studio*. Thank you for any help.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions