WAP to store 20 numbers (including positive & negative) in single dimensional arrayand display how many numbers are even positive,
odd positive and how many are negative.
Answers
Answered by
0
Answer:
Try it
Explanation:
import java.util.Scanner;
public class KboatSDAOddEvenSum
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int arr[] = new int[20];
System.out.println("Enter 20 numbers");
for (int i = 0; i < arr.length; i++) {
arr[i] = in.nextInt();
}
int neg = 0, posit = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] < 0)
neg+= arr[i];
else
posit += arr[i];
}
System.out.println("Negative numbers = " + neg);
System.out.println("Positive numbers = " + posit);
}
}
Answered by
0
Answer:
Hope it helps Thisis a different one
Attachments:
Similar questions