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
Why c is faster than c++?
What is the difference between null pointer and wild pointer?
What do you mean by a local block?
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0
What is the use of a semicolon (;) at the end of every program statement?
Is stack a keyword in c?
What does the && operator do in a program code?
When should you use a type cast?
What is the purpose of sprintf?
What are the different types of linkage exist in c?
When should the const modifier be used?
Why is c faster?
Are the variables argc and argv are local to main?
Explain pointer. What are function pointers in C?
What is this infamous null pointer, anyway?