Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

C language-sort with replacement method

0 votes
asked Mar 6, 2018 by Anthony DiNozzo (130 points)
Input a word and a letter. Then sort the word with letter from A to Z

input word: program

input letter: t

output: a g m o p r r t

2 Answers

0 votes
answered Mar 8, 2018 by Pugazharasan C
#include<stdio.h>
int main(){
    char word [50],letter;
    int ind,let;
    scanf("%s\n%c",word,&letter);
    for(ind=0;ind<26;ind++){
        if(ind+'a' == letter)
            printf("%c",letter);
        for(let = 0; word[let] !='\0'; let++){
            if(ind+'a' == word[let]){
                printf("%c",word[let]);
            }
        }
    }
}
0 votes
answered Mar 16, 2018 by anonymous
#include <stdio.h>

void main()

{

char s[20];

char ch;

int i,j;

scanf("%s",s);

scanf(" %c",&ch);

for(i=0;s[i];i++);

s[i]=ch;

for(i=0;s[i]-1;i++)

{

for(j=0;s[j]-1-i;j++)

{

if(s[j]<s[j+1])

{

s[i]=temp;

s[i]=s[j];

s[j]=temp;

}

}

}

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...