Copy the array A element in array B.


#include<iostream.h>
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
int a[5];
int b[5];
{
for(int i=0;i<=5;i++)
{
cin>>a[i];
b[i]=a[i];
}
for(i=0;i<=5;i++)
{
cout<<"Element of array B-->"<<b[i];
cout<<endl;
}
}
getche();
}
What is the question?

Note: int a[5];. The 'a' is an array with 5 elements. Your loops execute with index values 0, 1, 2, 3, 4, and 5. That is six elements, one too many.
Topic archived. No new replies allowed.