InterviewSolution
| 1. |
How to write a program to remove all duplicate characters in a string? |
|
Answer» #include #include int main() { char str[100]; int i, j, k; printf("\n Please ENTER any String : "); GETS(str); for(i = 0; i < strlen(str); i++) { for(j = i + 1; str[j] != '\0'; j++) { if(str[j] == str[i]) { for(k = j; str[k] != '\0'; k++) { str[k] = str[k + 1]; } } } } printf("\n The FINAL String after Removing All Duplicates = %s ", str); return 0; } Related Article: Google Adwords Interview Questions |
|