Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
#include <iostream.h>
#include <conio.h>

int main(int argc, char *argv[])
{


  int a[2],b[2],c[2],i,j,k;
  for(i=0;i<=1;i++)
  {
   cout<<"Enter values of first array ";
   cin>>a[i];
  }
  for(j=0;j<=1;j++)
  {
  cout<<"Enter values of second array ";
  cin>>b[j];
}
for(k=0;k<=1;k++)
{

 c[k]=a[i]+b[j];
 cout<<c[k]<<endl;
}
  getche();

}




The above program is for adding two arrays store it into third array but this does not give correct answer please help
Posted

1 solution

Quote:
c[k]=a[i]+b[j];

That is wrong: cahnge to:
C
c[k]=a[k]+b[k];
 
Share this answer
 
Comments
nv3 7-Dec-12 8:12am    
That was easy :-)
CPallini 7-Dec-12 8:59am    
Not so easy. The triple "K" is a bit scaring, after all.
:-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900