Professional Documents
Culture Documents
CPE 112 String Activity
CPE 112 String Activity
Problem #1
Input 1:
Black
Brick
Output 1:
Bck
Input 2:
Stray
Stay
Output 2:
Stay
Code:
#include <stdio.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
// Check the occurrence of letters in the second word and print common letters
printf("Common letters: ");
for (i = 0; i < len2; i++) {
if (letters[word2[i] - 'a'] > 0) {
printf("%c ", word2[i]);
letters[word2[i] - 'a']--;
}
}
printf("\n");
}
int main() {
char word1[100], word2[100];
printCommonLetters(word1, word2);
return 0;
}