Sunday, April 19, 2020

Linear Search in Perl

I wrote this program to demonstrate the concept of linear search using Perl programming language. Feel free to use this code in your assignments and projects in computer programming in Perl.

I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/

https://www.unlimitedbooksph.com/

Program Listing

# linear_search_array.pl
# Author   : Jake R. Pomperada,MAED-IT,MIT
# Date     : April 10, 2020   Friday  9:25 OM
# Location : Bacolod City, Negros Occidental
# Email    : jakerpomperada@gmail.com
# Website  : http://www.jakerpomperada.com

@$arr=(1..100);
$b=0,$num_input=0;
$c=0, $pos=0;
printf("\n");
printf("\t\tLinear Search in Perl");
printf("\n\n");
printf("\tEnter the array size : ");
chomp($num_input=<STDIN>);
printf("\n");
for($b=0; $b<$num_input; $b++)
{
     printf("\tEnter Array Elements Item No. %d: ",$b+1);   
     chomp($arr[$b]=<STDIN>);
}
printf("\n\n"); 
printf("\tEnter the number to be search : ");
chomp($num_input=<STDIN>);
for($b=0; $b<$num_input; $b++)
{
if($arr[$b]==$num_input)
{
$c=1;
$pos=($b+1);
break;
}
}
if($c==0)
{
printf("\n\n");
printf("\tSorry the number %d is not found from the list.",$num_input);
}
else
{
printf("\n\n");
    printf("\tThe number %d found at position %d.",$num_input,$pos);
}
printf("\n\n");
printf("\tEnd of Program");
printf("\n\n");

No comments:

Post a Comment