Answer to Question #31597 in C++ for MANMOHAN SHARMA
2013-06-05T07:34:46-04:00
1. "Write a function to find out common alphabets between two arrays. Length of array is not fixed and may contain other data type also.”
1
2013-06-06T08:58:32-0400
#include <iostream> #include <string> #include<iostream> using namespace std; /*"Write a function to find out common alphabets between two arrays. Length of array is not fixed and may contain other data type also.” */ const int n=10; int main() { char ar1[n]; char ar2[n]; char ch; int i=0; cout<<"enter 1st array& 0 -to exit\n"; cin>>ch; while (ch !='0') { ar1[i] = ch; ++i; cin>>ch; } cout<<"enter 2nd array\n"; int j=0; cin>>ch; while (ch!='0') { ar2[j] = ch; ++j; cin>>ch; } char w[n]; int count=0; for (int k=0;k<i;++k) { for (int h=0;h<j;++h) { if (ar1[k] == ar2[h]) { bool ind = true; for (int y=0;y<count ;++y) { if(ar1[k] == w[y]) {ind = false; break;} } if (ind == true) w[count++] = ar1[k]; } } } cout<<"Common letters\n"; for (int y=0;y<count ;++y) cout<<w[y]; cout<<endl; system ("PAUSE"); return 0; }
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:
C++
Comments
Leave a comment