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
Can i use “int” data type to store the value 32768? Why?
The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration
What are the advantages of Macro over function?
What is the best way to comment out a section of code that contains comments?
What is a pragma?
What is calloc() function?
Why c is procedure oriented?
What is c variable?
Can you add pointers together? Why would you?
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
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
When is a null pointer used?
Which one would you prefer - a macro or a function?
What happens if a header file is included twice?
Is it valid to address one element beyond the end of an array?