2012-10-29T09:49:47-04:00
a program in c++ using arrays to input 2 words and check whether the 1st word contains the 2nd word or not.
1
2012-10-29T11:21:03-0400
#include <iostream> using namespace std; int main () { charstring1[128], string2[128]; cout<< "Enter string1:" << endl; cin.getline(string1,sizeof(string1)); cout<< "Enter string2:" << endl; cin.getline(string2,sizeof(string2)); boolcontains = false; for(int i = 0; i < sizeof(string1); i++) { if(string1[i] == string2[0]){ for(int j = 0; j < sizeof(string2); j++) { if(string1[i] == string2[j]){ contains= true; } } } } if(contains) cout << string1 << " contains " << string2 << endl; system("pause"); return0; }
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 !
Learn more about our help with Assignments:
Adobe Flash
Comments