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


Please Help Members By Posting Answers For Below Questions

Write a function that will take in a phone number and output all possible alphabetical combinations

607


The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none

768


What are variables c?

624


Explain how do you determine whether to use a stream function or a low-level function?

632


In C programming, how do you insert quote characters (‘ and “) into the output screen?

898






What is the scope of global variable in c?

560


Explain what does a function declared as pascal do differently?

644


What are the advantages of external class?

598


Describe wild pointers in c?

644


What the advantages of using Unions?

675


Describe how arrays can be passed to a user defined function

786


What are the different types of pointers used in c language?

614


What is the difference between the expression “++a” and “a++”?

652


What are the back slash character constants or escape sequence charactersavailable in c?

689


What is a program?

669