Question
My current C program is as followes: #include int readElementsToArray(int array[]) //decide how many inputs will be put into the array { int n; printf(enter
My current C program is as followes:
#include
int readElementsToArray(int array[])
//decide how many inputs will be put into the array { int n; printf("enter elements into the array: "); for(int i = 0; i++;) scanf("%d",&array[i]); return n; }
void printArray(int array[], int n) { for(int i=0; i int EfficientBubbleSort(int A[], int n) { int exchange, i, j, temp; for (i = 0; i int MergeArrays(int A[], int B[], int C[], int n1, int n2) { for(int i = 0; i int main() { int A[20], B[20], C[40], Asize, Bsize, Csize; printf(" Enter elements to first array: "); Asize = readElementsToArray(A); printf(" Enter elements to second array: "); Bsize = readElementsToArray(B); printf(" First array elements in their original order:"); printArray(A, Asize) ; printf(" Second array elements in their original order:"); printArray(B, Bsize) ; EfficientBubbleSort(A, Asize); EfficientBubbleSort(B, Bsize); printf(" First array elements in their sorted order:"); printArray(A, Asize) ; printf(" Second array elements in their sorted order:"); printArray(B,Bsize) ; Csize = MergeArrays(A, B, C, Asize, Bsize); EfficientBubbleSort(C, Csize) ; printf("The new merged array in their sorted order:"); printArray(C, Csize) ; } it is a program designed to sort each vector and then merge and sort again,it works however i need my code to not have to ask for the number of elements in each vector, how would i modify my code to do so?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started