I saw this code from a website, this code concatenates the two arrays a & b..but i cant get how it works...can someone explain.? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I saw this code from a website, this code concatenates the two arrays a & b..but i cant get how it works...can someone explain.?

#include <iostream> using namespace std; int main() { int a[] = {1,2,3,4,5}; int b[] = {6,7,8,9,10}; int c[10]; for(int i=0; i<5; i++) { c[i] = a[i]; } for(int i=5; i<10; i++) { c[i] = b[i-5]; } for(int i=0; i<10; i++) { cout << c[i] <<" "; }

11th May 2018, 2:07 PM
RiGeL
RiGeL - avatar
1 Answer
+ 7
Inserts elements in array a to index 0 - 4 of array c. Inserts elements in array b to index 5 - 9 of array c.
11th May 2018, 2:17 PM
Hatsy Rei
Hatsy Rei - avatar