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

What is the output of the below program and how it is? void main() { static int var=5; printf("%d",var--); if(var) main(); }

8 Answers   MindFire, TCS, Tech Mahindra,


what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){ case 4:a+=a*r; case 3:a+=a*r; case 2:a+=a*r; case 1:a+=a*r; } } a.computes simple interest for one year b.computes amount on compound interest for 1 to 4 years c.computes simple interest for four year d.computes compound interst for 1 year

7 Answers   TCS,


How do you write a program which produces its own source code as its output?

4 Answers  


plz answer.... write a program that reads line (using getline) e.g."345", converts each line to an integer using "atoi" and computes the average of all the numbers read. also compute the standard deviation.

1 Answers  


c program to subtract between two numbers without using '-' sign and subtract function.

2 Answers  






what is software?

7 Answers   Wipro,


Convert the following expression to postfix and prefix X $ Y Z - M + N + P / Q / (R + S)

2 Answers  


What are the three constants used in c?

0 Answers  


write a program to display the array elements in reverse order in c language

16 Answers  


how to construct a simulator keeping the logical boolean gates in c

0 Answers  


Which is better oop or procedural?

0 Answers  


What is oops c?

0 Answers  


Categories