1D Array Methods Exercise
16 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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?

  • 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?

  • 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?

    <p>Integers (C)</p> Signup and view all the answers

    In the provided CSV file structure, what does the first line represent?

    <p>An integer indicating the number of records (C)</p> Signup and view all the answers

    How many marks are associated with each student's record in the given CSV file format?

    <p>4 (D)</p> Signup and view all the answers

    What will the output be if a user inputs a color that is in the color array?

    <p>The color exists. (D)</p> Signup and view all the answers

    What is the expected output when utilizing the Array.Reverse() method on an already sorted ascending array?

    <p>The array is reversed to descending order. (B)</p> Signup and view all the answers

    What is the purpose of the .Split() method in the context of reading records?

    <p>To separate the last name and first name from the marks. (B)</p> Signup and view all the answers

    If a user inputs an index 'i' of value 2, which value will be deleted from the array?

    <p>The value at index 2. (A)</p> Signup and view all the answers

    What should be done to the last element in the array after deleting an element?

    <p>It should be set to '0'. (A)</p> Signup and view all the answers

    What is the expected output when the program finds duplicates in the given array?

    <p>All duplicates present in the array should be listed. (D)</p> Signup and view all the answers

    Which operation is necessary before finding duplicates in the integer array?

    <p>Sorting the array. (D)</p> Signup and view all the answers

    How do you determine the student with the highest average based on the provided exercise?

    <p>By comparing the averages of all students. (D)</p> Signup and view all the answers

    What will happen if two students have the same average?

    <p>It is assumed that all averages are unique. (B)</p> Signup and view all the answers

    What should the program output after deleting an element from the array?

    <p>The array after deletion, sorted. (A)</p> 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() or Array.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.

    Quiz Team

    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.

    More Like This

    Use Quizgecko on...
    Browser
    Browser