Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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 extern c means?

0 Answers  


What is the difference between fread buffer() and fwrite buffer()?

0 Answers  


how to add two numbers without using arithmetic operators?

4 Answers  


Explain high-order bytes.

0 Answers  


What are conditional operators in C?

0 Answers   Adobe,






Is c++ based on c?

0 Answers  


how many error occurs in C language ?

22 Answers   Infosys, Wipro,


What is unary operator?

0 Answers  


What is a memory leak in structures? How can we rectify that?

2 Answers  


What is conio h in c?

0 Answers  


What are the types of data structures in c?

0 Answers  


What is d scanf?

0 Answers  


Categories