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

Why is #define used?

0 Answers  


how can i include my own .h file EX:- alex.h like #include<alex.h>, rather than #include"alex.h"

1 Answers  


Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)

5 Answers   IBM, KJH,


How do you view the path?

0 Answers  


i want to asked a question about c program the question is: create a c program that displays all prime numbers less than 500? using looping statement

5 Answers  






What is Memory leakage ?

2 Answers   HCL,


Write a function in c to find the area of a triangle whose length of three sides is given.

2 Answers  


How many header files are in c?

0 Answers  


What will be the result of the following C language program? main() { int a = 0; int b = 20; char x = 1; char y = 10; if(a,b,x,y) printf("Welcome"); }

1 Answers  


What are Storage Classes in C ?

32 Answers   CTS, HP, IBM, Maharaja Whiteline, Tamil Nadu Open University TNOU, TATA, TCS, Wipro,


How is null defined in c?

0 Answers  


How do you declare a variable that will hold string values?

0 Answers  


Categories