write a program to input 10 strings and compare without
using strcmp() function. If the character of one string
matches with the characters of another string , sort them
and make it a single string ???
example:- str1="Aakash" st2="Himanshu" str="Uday"
output:- Aakashimanshuday (please post the answer as quickly
as possible)



write a program to input 10 strings and compare without using strcmp() function. If the character o..

Answer / Aneej Yadav

```cn#include <stdio.h>n#include <string.h>nnvoid merge(char *arr[], int l, int m, int r) {n int i, j, k;n char temp[r + 1];n for (i = l; i <= m; i++) {n arr[m][j++] = arr[i];n }n i = l;n j = 0;n for (k = l; k <= r; k++) {n if (strcmp(arr[i], arr[k]) < 0) {n arr[++i] = arr[k];n } else if (j == 0 || strcmp(arr[j - 1], arr[k]) > 0) {n arr[++j] = arr[k];n }n }n for (; j >= 1; j--) {n temp[--i] = arr[j][--j];n arr[j][j + 1] = '';n }n}nvoid mergeSort(char *arr[], int l, int r) {n if (l < r) {n int m = (l + r) / 2;n mergeSort(arr, l, m);n mergeSort(arr, m + 1, r);n merge(arr, l, m, r);n }n}nint main() {n char strings[10][50];n int i;n printf(&quot;Enter 10 strings:n&quot;);n for (i = 0; i < 10; i++) {n scanf(&quot;%s&quot;, strings[i]);n }n mergeSort(strings, 0, 9);n printf(&quot;Sorted and merged string: &quot;);n for (i = 0; i < 10 - 1; i++) {n printf(&quot;%s&quot;, strings[i]);n }n printf(strings[9]);n return 0;n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

what is an ERP?

2 Answers   Infotech,


Why is c used in embedded systems?

1 Answers  


What is the scope of static variables?

1 Answers  


What is pass by value in c?

1 Answers  


main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); }

6 Answers  


What does %p mean c?

1 Answers  


Why should I use standard library functions instead of writing my own?

1 Answers  


The program to allow the characters from the input received and send this function to a function check if the characters between letters a to z is a function of y joins as the characters main and output to otherwise return to the original function of the y characters

0 Answers  


please tell me the logic for this C program : INPUT (string):ABCD OUTPUT :BCDA CDAB DABC

2 Answers   Mphasis,


What are the disadvantages of a shell structure?

1 Answers  


What are volatile variables?

1 Answers   Mind Tree,


we have to use realloc only after malloc or calloc ? or we can use initially with out depending on whether we are using malloc or calloc in our program ?

2 Answers  


Categories