Write a program to input 10 numbers into an integer array and print the single-digit positive numbers which are not present in the array.
Answers
Answered by
7
Answer:
import java.util.Scanner;
class Abcd{
public static void main(String[] args){
int[] num = new int[10];
Scanner scan = new Scanner(System.in);
System.out.println("Enter 10 numbers");
for(int i=0;i<10;i++){
num[i]=scan.nextInt();
}
boolean b = false;
for(int i = 1; i<10 ; i++){
b=true;
for(int n: num){
if(i == n){
b = false;
break;
}
}
if(b==true)
System.out.println(i);
}
}
}
I wrote it in BlueJ environment
Similar questions