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 |
How do I access command-line arguments?
What are two dimensional arrays alternatively called as?
How to print India by nested loop? I IN IND INDI INDIA
What is openmp in c?
What is difference between function overloading and operator overloading?
What is ## preprocessor operator in c?
Eight queens puzzle
What is an identifier?
Explain goto?
what are the advantage of pointer variables? write a program to count the number of vowels and consonants in a given string
what is the difference between while and do while?
What does the error 'Null Pointer Assignment' mean and what causes this error?