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
What are the application of void data type in c?
How can I list all of the predefined identifiers?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
What is page thrashing?
What is pragma c?
Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.
Subtract Two Number Without Using Subtraction Operator
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
Can an array be an Ivalue?
What is typedef struct in c?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
What is meant by inheritance?
what do you mean by enumeration constant?
write a c program in such a way that if we enter the today date the output should be next day's date.