Question

2. Show code for function, appendArray, based on the following prototype: int appendArray(int array1M[], int iCounti,int arra

Must be in C.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int appendArray(int array1M[], int iCount1, int array2M[], int iCount2, int iMaxArray1) {

if (iCount1 + iCount2 > iMaxArray1) {

printf("Sorry, there are not enough empty spaces in array1M!!");

return iCount1;

}

for (int i=0; i<iCount2; i++) {

array1M[i + iCount1] = array2M[i];

}

printf("Contents of array1M after appending is: \n");

for (int i=0; i<iCount1 + iCount2; i++) {

printf("%d ", array1M[i]);

}

return (iCount1 + iCount2);

}

int main(void) {

int iCount1 = 3, iCount2 = 2;

int array1M[8];

array1M[0] = 11;

array1M[1] = 12;

array1M[2] = 13;

int array2M[iCount2];

array2M[0] = 24;

array2M[1] = 25;

printf("\n\nNew size of array1M = %d", appendArray(array1M, iCount1, array2M, iCount2, 8));

return 0;

}

saved clang version 6.0.0-1ubun Contents of array1M after 11 12 13 24 25 main.c 1 #include<stdio.h> 3 int appendArray (int ar

Add a comment
Know the answer?
Add Answer to:
Must be in C. 2. Show code for function, appendArray, based on the following prototype: int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT