Question: in c + + Assume an array of sorted integers with Students ID . Write a program to insert few Student IDs in the array
in c Assume an array of sorted integers with Students ID Write a program to insert few Student IDs in the array such that the array remains sorted. Assume an array sid to start with. Solution:
Find out how many user ids need to be inserted Check if those Ids already existing. IF so don't insert them. Just print a message the element if found at the index position If not found, insert them in such a way that the arrays remain sorted #include
using namespace std;
int findIdint int int;
void insertIdint int int;
int main
const int MAXSIZE ;
int sidMAXSIZE;
int index, id;
To insert more numbers
int num, size ;
cout "How many numbers do you want to insert? ;
cin num;
cout "Enter the student ids: ;
Enter your code
cout "The array with all the elements inserted are: ;
Enter your code
should return the index of val if it is present in the array
otherwise return
int findIdint val, int arrId int sz
Enter your code
void insertIdint val, int arrId int sz
Enter your code
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
