0% found this document useful (0 votes)
15 views

LINEAR Structures

This C++ program implements a linear search on a string using structures. It takes a string and searches for a character within it. The string and searching character are input by the user. It loops through each character of the string and checks if it matches the searching character. If a match is found, it prints "found", otherwise it prints "Not found" after completing the search.

Uploaded by

Swapnil Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

LINEAR Structures

This C++ program implements a linear search on a string using structures. It takes a string and searches for a character within it. The string and searching character are input by the user. It loops through each character of the string and checks if it matches the searching character. If a match is found, it prints "found", otherwise it prints "Not found" after completing the search.

Uploaded by

Swapnil Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Q 5. WAP to impliment lineasr search with structures .

#include<iostream.h>
#include<conio.h>
#include<process.h>
struct linear
{
char str[20],s;
}l;
void main()
{
clrscr();
cout<<"Enter a string :\n";
cin>>l.str;
cout<<"Enter a searching element :\n";
cin>>l.s;
for(int i=0;l.str[i]!='\0';i++)
if(l.s==l.str[i])
{
cout<<"found";
exit(1);
getch();
}
cout<<"Not found";
getch();
}

You might also like