Question #47609

Write a program to get an array of Strings from the user and then accept a string to find in the array. The program should print ‘Found’ if the value is present in the array else print ‘Not Found’.

Enter the number of elements in the String:
5
Enter a String:
abc
Enter a String:
def
Enter a String:
xyz
Enter a String:
123
Enter a String:
Pqr

Enter a String to search:
xyz
Output: Found



help me to solve this
1

Expert's answer

2015-01-19T03:44:27-0500

Answer on Question# 47609- <engineering> - <other>

Program:


#include <iostream>
#include <string>
using namespace std;
int main()
{
int n;
cout<<"Enter the number of elements in the String:";
cin>>n;
string *mas=new string[n];
int i;
for(i=0;i<n;i++) (=""><n<<"i):";
cin>>mas[i];
}
string strSearch;
cout<<"Enter a String for search: ";
cin>>strSearch;
int res=-1;
for(i=0;i<n;i++) (=""><n;i++)="" (ir(strsearch="mas[i])" (res="1;" (strsearch="mas[i])" (res<i;="" 1;="" 1;}="" 5):="" 5):="" else="" for="" i++)="" if(res<0)="" not="" numbr="" return="" strSearch="mas[i])" strSearch:="" {="" }="" }<n="" }<n;i++)="" }<n;i++)="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;i++)}="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;="" }<n;

txt

Enter the number of elements in the String:5

Enter a String <1 from 5>: abc

Enter a String <2 from 5>: cde

Enter a String <3 from 5>: fgh

Enter a String <4 from 5>: ikl

Enter a String <5 from 5>: mno

Enter a String for search: cde

Output: Found_

```

https://www.assignmentexpert.com/


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS