top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to remove the repetition character occurrence from given string using C?

+3 votes
445 views
How to remove the repetition character occurrence from given string using C?
posted Feb 8, 2016 by Spoorthi Jain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
#include<stdio.h>
#include<string.h>

main()
{
char a[100],b[100]={0};
printf("Enter the string\n");
scanf("%s",a);
int f=strlen(a);
int i,j,k=0,count=0;
for(i=0;i<f;i++)
{
for(j=0;j<i;j++)
{
if(a[i]==b[j])
{
count=1;
}
}
if(count==0)
{
b[k++]=a[i];

}
count=0;
}

for(j=0;j<strlen(b);j++)
{
printf("%c",b[j]);
}
} 
answer Feb 9, 2016 by Shivaranjini
Similar Questions
0 votes

Enter character: r
Enter string: programming
Output: Positions of 'r' in programming are: 2 5
Character 'r' occurred for 2 times

+2 votes

Remove duplicate characters from given string?

Input: "cutcopypaste"
Output: "uoyase"

+1 vote

How to find first unrepeated character in string using C/C++?

Input       Output     
abc         a    
aabcd       b
aabddbc     c
+3 votes

I need help in writing the code where I enter the input in which each char is followed by its occurrence and output should be absolute string.

Example
Input a10b5c4
Output aaaaaaaaaabbbbbcccc

...