MY mENU


Friday, 19 April 2013

Adding two Arrays and finding the third array is positive or negative???

import java.util.*;
import java.lang.*;
import java.io.*;
class AddArrays1
{
public static void main(String[] args)
{
//Scanner sc=new Scanner(System.in);

int a[]={1,2,3};
int b[]={2,3,-4};
int c[]=new int[3];
for(int i=0;i{
c[i]=a[i]+b[i];
System.out.println(c[i]);
}
for (int i=0; i{
if (c[i] > 0) {
System.out.println(c[i]+ " is positive");
} else {
System.out.println(c[i] + " is not positive");
}
}
}
}

No comments:

Post a Comment