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



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

Answer / 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

More C Interview Questions

how can i make a program with this kind of output.. Enter a number: 5 0 01 012 0123 01234 012345 01234 0123 012 01 0

4 Answers   Wipro,


How do you search data in a data file using random access method?

0 Answers  


wat are the two methods for swapping two numbers without using temp variable??

2 Answers  


what are bps & baud rates? differentiate these two?

2 Answers   TCS,


what wud be the output? main() { char *str[]={ "MANISH" "KUMAR" "CHOUDHARY" }; printf("\nstring1=%s",str[0]); printf("\nstring2=%s",str[1]); printf("\nstring3=%s",str[2]); a)string1=Manish string2=Kumar string3=Choudhary b)string1=Manish string2=Manish string3=Manish c)string1=Manish Kumar Choudhary string2=(null) string3=(null) d)Compiler error

9 Answers   Infosys,


any string of bits of length 'n' represents a unique non- negative integer between.............?

2 Answers  


a simple c program using 'for' loop to display the output 5 4 3 2 1

2 Answers   Google,


What is Function Pointer? Explain with example?

3 Answers  


How can you increase the size of a dynamically allocated array?

0 Answers   TISL,


What is meant by int main ()?

0 Answers  


Write a program or provide a pseudo code to flip the 2nd bit of the 32 bit number ! (Phone Screen)

1 Answers   NetApp, PTU, Wipro,


If we give two names then this displays the connection between the two people. It is nothing but flames game

1 Answers  


Categories