write a c prog for removing duplicate character from an
array and sorting remaining elements using a single array
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 |
What is the c value paradox and how is it explained?
c program to subtract between two numbers without using '-' sign and subtract function.
How can you check to see whether a symbol is defined?
What is the value of h?
write a c program to find the roots of a quadratic equation ax2 + bx + c = 0
11 Answers CSC, St Marys, TATA,
Explain how can you check to see whether a symbol is defined?
How can I list all of the predefined identifiers?
Do you know pointer in c?
What happens if a header file is included twice?
#include<stdio.h> { printf("Hello"); } how compile time affects when we add additional header file <conio.h>.
How can I delete a file?
What is the meaning of ?