Write a program to print all the 3 digit prime numbers. 17) Write a program to input 10 numbers. Input another number. If the number is present in the list then print "NUMBER FOUND" otherwise print " NUMBER NOT FOUND".
please answer this question with variable description and comment
Answers
Answered by
4
Question:-
- Write a program to input 10 numbers. Input another number. If the number is present in the list then print "NUMBER FOUND" otherwise print " NUMBER NOT FOUND".
Code:-
package Coder;
import java.util.*;
class Code
{
public static void main (String ar [])
{
/*
*Code written by
*@swetank232894
*/
Scanner sc=new Scanner (System.in);
int a[]=new int[10];
System.out.println("Enter ten elements in an array");
int f=0;
for(int I=0;I<10;I++)
{
a[I]=sc.nextInt();
}
System.out.println("Enter number to be searched");
int n=sc.nextInt();
for(int i=0;i<10;i++)
{
if (n==a[i])
{
f=1;
break;
}
}
if(f==1)
System.out.println("Number found");
else
System.out.println("Number not found");
}
}
______
Variable Description:-
- I:- loop variable
- i:- loop variable
- f:- flag variable
- n:- to input the number to be searched
- a:- to store multiple numbers (10 numbers)
_______
•Output attached
Attachments:
Similar questions