Skip to content

Instantly share code, notes, and snippets.

@krshubham
Created March 16, 2021 05:44
Show Gist options
  • Save krshubham/6ac873c045e46e076468e7fcd09d18ab to your computer and use it in GitHub Desktop.
Save krshubham/6ac873c045e46e076468e7fcd09d18ab to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main() {
int n;
// Take the input for n, number of strings
scanf("%d", &n);
char strings_given[50][100];
for(int i = 0; i < n; i++) {
//Read the input string from the user
scanf("%s", strings_given[i]);
}
//For each character from a to z check if it is present in all the strings
for(char c = 'a'; c <= 'z'; c++) {
int count = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < strlen(strings_given[i]); j++) {
if(tolower(strings_given[i][j]) == c) {
count++;
break;
}
}
}
if(count == n) {
printf("%c", c);
}
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment