Question: CSCI 1 2 1 Project 0 7 Introduction Purpose The purpose of this project is to help the students to reinforce the knowledge from Chapter
CSCI Project
Introduction
Purpose
The purpose of this project is to help the students to reinforce the knowledge from Chapter of the textbook.
Objectives
Review topdown design
Understand and apply the syntax of array
Understand and apply the linear search, selectsort, insertsort, and bubblesort algorithms
Problem Description
Finish the implementation of the following program. Keep two things in mind:
Study the code carefully.
Add menu function accordingly
Students should implement and test the following functions:
void fillarrayint arr int size;
precondition: The arr has actual size that is greater than or equal to
size
postconditiont arr arrsize is filled from keyboard
void printarrayint arr int size;
precondition: The arr has actual size that is greater than or equal to
size
postcondition: arr arrsize is printed to screen with
elements per line
int linearsearchint arr int size, int key;
precondition: arr has given size
postcondition: The index of first occurrence of key in arr is returned. If
the key cannot be found in arr, is returned
void selectsortint arr int size;
precondition: arr has given size
postcondition: the elements in arr are rearranged from least to largest
void insertsortint arr int size;
precondition: arr has given size
postcondition: the elements in arr are rearranged from least to largest
void bubblesortint arr int size;
precondition: arr has given size
postcondition: the elements in arr are rearranged from least to largest
Of course, a menu function is needed. The main function will look like following:
int main
int choice;
int a;
do
menu;
cout "Enter your choice: ;
cin choice;
switchchoice
case :
fillarraya;
cout "Enter the key you want to search: ;
int key;
cin key;
int index linearsearcha key;
ifindex
cout & "The key key is not in array
;
else
cout "The key key is #index
element in array
;
break;
case :
fillarraya;
selectsorta;
cout "After sort, the array is:
;
printarraya;
break;
case :
fillarraya;
insertsorta;
cout "After sort, the array is:
;
printarraya;
break;
case :
fillarraya;
bubblesorta;
cout "After sort, the array is:
;
printarraya;
break;
case :
cout "Thank you for using the array functions
;
break;
default:
cout "Wrong choice. Please choose from menu: ;
break;
whilechoice ;
return ;
This is a good example to show how to write the test program to test functions.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
