Write a program to store following numbers in an array
3 10 -15 20 12 8 -3 7
then display all the numbers without showing negative numbers(i.e. -15 and -3)
public class App {
/**
* The start point of the program
*
* @param args
*
*/
public static void main(String[] args) {
int numbers[] = { 3, 10, -15, 20, 12, 8, -3, 7 };
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] < 0) {
System.out.print(numbers[i] + " ");
}
}
}
}
Comments
Leave a comment