Take an array of 10 elements. Split it into middle and store the elements in two dfferent arrays. E.g.-
INITIAL array :
58 24 13 15 63 9 8 81 1 78
After spliting :
58 24 13 15 63
9 8 81 1 78
Answers
Answer:
hlo
Explanation:
please mark me as brainliest
Answer:
#include <iostream>
using namespace std;
void printg(int arr[]){
for (int i = 0; i < 5; i++)
{
cout<<arr[i]<<" ";
}
cout<<endl;
return;
}
int main(){
cout<<"Enter your first array of 10 elements "<<endl;
int arr[10], ark[5], art[5];
for (int i = 0; i < 10; i++)
{
cin>>arr[i];
}
for (int i = 0; i <5; i++)
{
ark[i]=arr[i];
}
for (int i = 0; i < 5; i++)
{
art[i]=arr[i+5];
}
printg(ark);
printg(art);
return 0;
}
Explanation:
here i made 3 arrays arr[] ,ark[] and art[] of size 10 ,5,5 respectively then I input numbers from users in first array then i started a for loop and and put first five digits of the array in the ark[] array then i started another for loop where I was giving numbers 1,2...5 soo i insters arr[i+5} = art[i] so art[] array now has last 5 digits of the original array and ark[] array already has starting 5 so there you have it array is devided into two parts i didn't wanted to use for loop twice to print them so i created a void print function but you can also use for loop two times to print both arrays so don't be confused about that
I hope you understood i am not a pro either