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?
- Array.Reverse() (correct)
- Array.OrderDescending()
- Array.Sort()
- Array.Invert()
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?
- Array.Contains()
- Array.Find()
- Array.Exists()
- Array.IndexOf() (correct)
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?
- last_name_first name_E02_3.cs
- last_name_first name_U4_E02_3.cs (correct)
- U4_E02_3_last_name_first name.cs
- last_name_E02_3.cs
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?
In the provided CSV file structure, what does the first line represent?
In the provided CSV file structure, what does the first line represent?
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?
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?
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?
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?
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?
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?
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?
Which operation is necessary before finding duplicates in the integer array?
Which operation is necessary before finding duplicates in the integer array?
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?
What will happen if two students have the same average?
What will happen if two students have the same average?
What should the program output after deleting an element from the array?
What should the program output after deleting an element from the array?
Flashcards
Array.Reverse() method
Array.Reverse() method
A method in C# that can be used to reverse the order of elements in a one-dimensional array.
Array.IndexOf() method
Array.IndexOf() method
A method in C# that searches an array for a specific element and returns its index position, or -1 if the element is not found.
CSV (Comma-Separated Values) file
CSV (Comma-Separated Values) file
A file format used to store tabular data, where data is separated by commas and each line represents a row.
One-Dimensional Array
One-Dimensional Array
Signup and view all the flashcards
Sorting an Array
Sorting an Array
Signup and view all the flashcards
Key-Value Pair
Key-Value Pair
Signup and view all the flashcards
Interactive Program
Interactive Program
Signup and view all the flashcards
Tree Data Structure
Tree Data Structure
Signup and view all the flashcards
Split() Method
Split() Method
Signup and view all the flashcards
What is an array?
What is an array?
Signup and view all the flashcards
For-loop
For-loop
Signup and view all the flashcards
Double data type
Double data type
Signup and view all the flashcards
Minimum value
Minimum value
Signup and view all the flashcards
Maximum value
Maximum value
Signup and view all the flashcards
Average
Average
Signup and view all the flashcards
Deleting an element from an array
Deleting an element from an array
Signup and view all the flashcards
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.