i need help for this program, i dont know how t split the array, can u please ad
ID: 3544687 • Letter: I
Question
i need help for this program, i dont know how t split the array, can u please add to my code that part
i need it for C
Write a code that declares an array of 20 elements. Fill the array with random numbers that are between 0 and
99. In addition, declare two other arrays that are 10 elements each. Split the large array in the two small arrays.
The leftmost 10 elements of the large array should go in one of the small arrays. The rightmost 10 elements of
the large array should go in the other small array. Below is a sample output.
Your program should:
? Set the seed of the
Printing the large array... 63 2 83 79 91 40 99 53 37 20 70 50 85 70 81 15 45 36 51 43 Printing the first half... 63 2 83 79 91 40 99 53 37 20 Printing the second half... 70 50 85 70 81 15 45 36 51 43Explanation / Answer
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int arr[20];
int arr1[10];
int arr2[10];
int i,j=0;
srand( time(0));
for(i=0;i<=19;i++)
arr[i]=rand()%100;
printf("array: ");
for(i=0;i<=19;i++){
printf("%d ", arr[i]);
}
//printf"("array: ");
for(i=0;i<=19;i++){
if(i<10){
arr1[i]=arr[i];
}else{
arr2[j]=arr[i];
j++;
}
}
for(i=0;i<10;i++){
printf("%d ", arr1[i]);
}
for(i=0;i<10;i++){
printf("%d ", arr2[i]);
}
//system("PAUSE");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.