Given two character arrays, find the common characters. eg A[] = {'a', 'x', 'y', 'z'} B[] = {'l', 'z', 'a', 'm', 'n'} Output: {'a', 'z'} Click for Solution |
-
Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 681
A #include<stdio.h> #include<conio.h> void main() { char a1[100]; char a2[100]; char ch1[255]={0,0}; char ch2[255]={0,0}; int i,l1,l2; clrscr(); gets(a1); gets(a2); for(l1=1;a1[l1]!='\0';l1++); for(l2=1;a2[l2]!='\0';l2++); for(i=0;i<l1;i++) { ch1[a1[i]]=1; } for(i=0;i<l2;i++) { ch2[a2[i]]=1; } for(i=0;i<255;i++) { if(ch1[i]==1 & ch2[i]==1) printf("%c\t",i); } getch(); }
Explore
- GPL4you
- Home
- Prepdoor - Online Mock Test
- About
- FAQs
- Contact
- Contact Us
© 2011 - gpl4you | All Rights Reserved.