Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Merging Array

$
0
0
I need help with an assignment, I have to tell the user to input 13 integers in array 1 which will only take 13 integers, and 5 in array 2 which will only take 5 integers. After that, the two arrays will combine into array 1 to make 18 integers. I have the user put in both into array 1 and array 2, I just don't know how to combine them into array 1 because I can only use those two arrays and no third array to put into...

This is what I have so far.

#include<stdio.h>

int main()

{
        int array_a[18], array_b[5];
        int input1, input2;

        input1 = 0;

        printf("Please enter 13 integers: ");

                while(input1<13) /*This while loop will only take 13 integers for the first array*/
                {
                scanf("%d", &array_a[1]);

                input1++;
                }
        printf("Now enter 5 integers: ");

        input2 = 0;

                while(input2<5) /* And this one will only take 5 */
                {
                scanf("%d", &array_b[1]);

                input2++;
                }



return 0;
}




Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>