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
What are the different types of control structures?
Explain high-order and low-order bytes.
Explain what is operator promotion?
Why dont c comments nest?
What do you mean by invalid pointer arithmetic?
How is a null pointer different from a dangling pointer?
What is the difference between int main and void main?
What are reserved words with a programming language?
What does sizeof return c?
Are c and c++ the same?
Is flag a keyword in c?
Explain Function Pointer?
What is a header file?
Explain the concept and use of type void.
while initialization of array why we use a[][2] why not a[2][]...?