Friday, October 18, 2019

Linear Search Using Pointers in C

A simple program linear search using pointers in C was written by my friend sir Ernel Fadriquilan in the Turbo C compiler. Thank you, sir Arnel for sharing this program with us sir.

I am currently accepting programming work, 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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.


Program Listing

//One Dimensional Array || Searching
#include<stdio.h>
#include<conio.h>
#include<string.h>

char* arey[10];

void areyin()
{
int i;
printf("Enter 10 numbers:");
for(i=0;i<=9;i++)
{
printf("%d.",i+1);scanf("%s",&arey[i]);
}
}

void locate(char* a)
{
int i;
int found;
for(i=0;i<=9;i++)
{
if(strcmp(a,arey[i])==0)
{
found=1;
break;
}
else
found=0;
}
if(found==1)
printf("%s is inside the room. Seat number %d",a,i+1);
else
printf("Not found!");
}

void main()
{
char* num;
clrscr();
areyin();
printf("Enter number to locate:");scanf("%s",&num);
locate(num);
getch();
}

No comments:

Post a Comment