+ 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] <<" "; }
1 Resposta
+ 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.