public class ArrayAddition {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] a={1,2,3};
int[] b={2,3,4};
int[] c=new int[a.length];
for (int i = 0; i < a.length; i++)
{
for (int j = 0; j < b.length; j++)
{
if(i==j)
{
c[i]=a[i]+b[j];
System.out.print(c[i]+" ");
}
}
}
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] a={1,2,3};
int[] b={2,3,4};
int[] c=new int[a.length];
for (int i = 0; i < a.length; i++)
{
for (int j = 0; j < b.length; j++)
{
if(i==j)
{
c[i]=a[i]+b[j];
System.out.print(c[i]+" ");
}
}
}
}
}
No comments:
Post a Comment