Podcast
Questions and Answers
What method can be used to sort an array in descending order after sorting it in ascending order?
What method can be used to sort an array in descending order after sorting it in ascending order?
If a user inputs a color that does not exist in the color array, what method can be used to check for the color's presence?
If a user inputs a color that does not exist in the color array, what method can be used to check for the color's presence?
What is the proper naming convention for the file that stores the code for question 3?
What is the proper naming convention for the file that stores the code for question 3?
What data type must the user input when required to provide 5 integers for sorting?
What data type must the user input when required to provide 5 integers for sorting?
Signup and view all the answers
In the provided CSV file structure, what does the first line represent?
In the provided CSV file structure, what does the first line represent?
Signup and view all the answers
How many marks are associated with each student's record in the given CSV file format?
How many marks are associated with each student's record in the given CSV file format?
Signup and view all the answers
What will the output be if a user inputs a color that is in the color array?
What will the output be if a user inputs a color that is in the color array?
Signup and view all the answers
What is the expected output when utilizing the Array.Reverse() method on an already sorted ascending array?
What is the expected output when utilizing the Array.Reverse() method on an already sorted ascending array?
Signup and view all the answers
What is the purpose of the .Split() method in the context of reading records?
What is the purpose of the .Split() method in the context of reading records?
Signup and view all the answers
If a user inputs an index 'i' of value 2, which value will be deleted from the array?
If a user inputs an index 'i' of value 2, which value will be deleted from the array?
Signup and view all the answers
What should be done to the last element in the array after deleting an element?
What should be done to the last element in the array after deleting an element?
Signup and view all the answers
What is the expected output when the program finds duplicates in the given array?
What is the expected output when the program finds duplicates in the given array?
Signup and view all the answers
Which operation is necessary before finding duplicates in the integer array?
Which operation is necessary before finding duplicates in the integer array?
Signup and view all the answers
How do you determine the student with the highest average based on the provided exercise?
How do you determine the student with the highest average based on the provided exercise?
Signup and view all the answers
What will happen if two students have the same average?
What will happen if two students have the same average?
Signup and view all the answers
What should the program output after deleting an element from the array?
What should the program output after deleting an element from the array?
Signup and view all the answers
Study Notes
Exercise 02 - 1D Array Methods
-
File Naming Convention: Rename program files to
last_name_first_name_U4_E02_#.cs
(where # is the question number) before submission.
Question 1
- Ascending Order: Write a program that takes 5 integer inputs from the user and then sorts and displays them in ascending order.
-
Descending Order: Output the same integers in descending order, using the
Array.Reverse()
method.
Question 2
-
Color Check: Create a string array containing colors. Prompt the user for a color, and check if that color exists within the array. Use the
Array.IndexOf()
method.
Question 3
-
Input CSV: The input file
input.csv
contains student names and their marks. The first line has the number of records. Each following pair of lines represents a student and their scores. -
Output Requirements: Calculate minimum, maximum, and the average score for each student and output it. Output the name and average of the student with the highest average.
Question 4
-
Array Manipulation: Create an array of 5 doubles, taking user input for an index, delete the value at that index by shifting all elements to the left.
-
Element Replacement: The last element should be set to 0.
-
Sorting: Sort the resulting array and display it.
Question 5
-
Duplicate Finder (Optional): Find and output all duplicate integers within a given array of size 20, containing integers between 1 and 10. The array is
int[] myInts = {3, 5, 6, 9, 10, 10, 3, 7, 5, 4, 2, 1, 2, 4, 3, 7, 8, 5, 2, 6};
Question 6
-
Array Methods Comparison (Optional): Research and describe scenarios where
Array.BinarySearch()
orArray.IndexOf()
should be used. Document your answer in a .txt file.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz focuses on 1D array methods in C#. You will tackle tasks such as sorting integers, checking for colors in an array, and processing student scores from a CSV file. Each question will help you solidify your understanding of these programming concepts.