C++ Prac
C++ Prac
C++ Prac
2. Write a function called displayArray() to receive the arrNames array and display a
numbered list of the content of the array.
3. Example of out if the function is called:
Assign the name in the random index position from the arrNames
array to the arrPresent using the counter of the for loop.
Assign “ “ in the random index position in the arrNames to clear the
name from arrNames.
NOTE: arrNames should be filled with empty strings once the for loop is done. All the
names should then be assigned to arrPresent in random positions in the array.
1
Call the displayArray() function passing the arrPresent array to the function to see
the shuffled list of names.
Example of shuffled list of names in the arrPresent array:
NOTE: The list will be different each time when the code is executed due to random
selection of names.
5. Write code to allow the user to swap names in the arrPresent array.
Use a while loop which asks the user whether a swap needs to be done or not. If Y,
call the displayArray() function to display the numbered list of names from the
arrPresent array.
Ask the user to enter the number of the student on the list who wants to swap.
Ask the user to enter the number of the student on the list who is willing to swap.
Write code to swap the two names.
Example of input and output to swap two names. The program must be able to swap
more names until the user enters n.
2
6. Write code to allow the user to enter the marks of the students as they present their
projects using a for loop. Use the arrPresent array to display the name and enter the
mark.
NOTE: The arrPresent array and the arrMarks array are parallel arrays because the
elements of the arrays are related.
7. Write a function called displayMarks() that will receive the arrPresent array and the
arrMarks array and display a numbered list of the names and marks of the students.
3
Call the findBestProject() function from the main function and display the name of
the student with the best mark and the mark using the index value that was returned
by the function..
Example of output:
4
Rubric Mark
Array Declaration and Initialization (3 Marks)
3 pts: Arrays (arrNames, arrPresent, arrMarks) are correctly declared and
initialized as per instructions. 3
2 pts: Arrays are declared and initialized with minor issues.
1 pts: Arrays are declared but incorrectly initialized.
0 pts: Arrays are not declared or initialized correctly.