Structure of the Problem Requirements
Array searching is very important term in programming. Arrays cover a strong side of coding and use every where in all types of programming. In this problem we will check the existence of a number in an array. First, user will enter 5 numbers and then enter a number to check that number exist in array or not.
Source Code
package com.ancodingpoints.www;
import java.util.Scanner;
public class Array_Searching {
public static void main (String [] args )
{
Scanner input = new Scanner (System.in);
int num [] = new int [5];
int s =0;
for (int i = 0; i<5; i++)
{
System.out.println(" Enter Your Number ");
num[i] = input.nextInt();
}
System.out.println(" Enter Your Number to search in Array ");
s = input.nextInt();
for(int i=0; i<5;i++)
{
if (num[i] == s)
{
System.out.println(" Your Number Exist in Array!");
}
}
}
}
Output of the Program
Java Search Number |
Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.
0 comments:
Post a Comment