write a c prog for removing duplicate character from an
array and sorting remaining elements using a single array

Answer Posted / b sohan lal

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s[15],a[15];
int i,j,n;
clrscr();
printf("enter the string");
scanf("%s",s);
for(i=0;s[i]!='\0';i++)
{
if(s[i]!=s[i+1])
a[i]=s[i];
}
n=strlen(a);
for(i=0;s[i]!='\0';i++)
{
for(j=0;j<=n-i-1;j++)
{
if(a[j]>=a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("the sorted string is:%s",a);
getch();
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can i use “int” data type to store the value 32768? Why?

742


The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration

613


What are the advantages of Macro over function?

1178


What is the best way to comment out a section of code that contains comments?

761


What is a pragma?

656






What is calloc() function?

612


Why c is procedure oriented?

556


What is c variable?

540


Can you add pointers together? Why would you?

628


c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above

721


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2319


When is a null pointer used?

624


Which one would you prefer - a macro or a function?

588


What happens if a header file is included twice?

574


Is it valid to address one element beyond the end of an array?

661