guys i making a programme in this i have to merge two arrays into one new array but this code does not run at run time ,compiler does not chow any error

int k[100][100];
for (int i=0;i<n;n++)
{

    k[i][i]=k[array_1[i]][array_2[i]];


}

for (int i=0;i<n;i++)
{
    cout<<k[i][i];
}

here array_1 is my first array and array_2 is second array

You are only filling up the diagonal of a 100x100 matrix with two one dimensional arrays. Is that your intention? What is the value of n?

What ddanbe is trying to say, is that you need to show ALL of your code.

@basit 3, what you are trying to do is unclear. Can you put up the complete code ?

ok i post a full code

#include <iostream>
using namespace std;

int main()
{ 

int n;
int array_1[100];
int array_2[100];
cout<<"inter size of array 1: "<<endl;
cin>>n;

cout<< "enter "<<n<<" items of array 1\n";
for (int i=0;i<n;i++)
{
cin>>array_1[i];

}

system("cls");

int m;
cout<<"inter size of array 2: "<<endl;
cin>>m;

cout<< "enter "<<n<<" items of array 2\n"<<endl;
for (int i=0;i<m;i++)
{
cin>>array_2[i];

}

int k[100][100];
for (int i=0;i<n;n++)
{

k[i][i]=k[array_1[i]][array_2[i]];


}

for (int i=0;i<n;i++)
{
cout<<k[i][i];
}

system("PAUSE");
return 0;
}

What is that n++ doing on line 34?

Change line 34 to for (int i=0;i<n;i++) instead of for (int i=0;i<n;n++)

oh i see ,thankx

There is much more than the n++.
Leave the m out your two arrays have to be equal.
Suppose array_1 = { 2, 3 };
and array_2 = { 5, 6 };
Now consider this piece of your code, a bit modified:

int one = 0;
    int two = 0;
    for (int i = 0; i < n; i++)
    {
        one =array_1[i];
        two = array_2[i];
        k[i][i] =k[one][two];
    } 

The n++ has changed to i++
But in the loop you are setting(initializing) as a first element k[0][0] = k[2][5];
Think about the value that k[2][5] holds.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.