To Write a C program to remove the repeated characters in
the entered expression or in entered characters(i.e)
removing duplicates.

Answers were Sorted based on User's Feedback



To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / naveen

#include<stdio.h>
#include<string.h>
int main()
{
char a[100];
char b[100];
int i,j,k,l,m=0;
printf("enter the string
");
scanf("%s",a);
l=strlen(a);
for(i=0;i<l;i++)
{
k=0;
for(j=0;j<l;j++)
{
if(a[i]==b[j])
{
k++;
}
}
if(k==0)
{
b[m]=a[i];
m++;
}
}
b[m]='';
strcpy(a,b);
printf("after removing duplicates
");
printf("%s
",a);
return 0;

}

Is This Answer Correct ?    2 Yes 2 No

To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / ankith

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void check(char c,char str[],int len)
{
while(*(str+len))
{
if(str[len]==c)
str[len]='/';
len++;
}
}

void main()
{
char str[100];
char p[100],flag='/',c;
int llen=0,flen=0;
scanf("%s",str);
while(str[flen])
{
if(str[flen]=='/')
{
flen++;
continue;
}
else
{
c=str[flen++];
p[llen++]=c;
check(c,str,flen);
}
}
printf("%s ",p);
}

Is This Answer Correct ?    0 Yes 0 No

To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / avinash

#include<stdio.h>
int main()
{int i,j,k;
char a[]="avinash";


for(i=0;i=5;i++)
{

for(j=(i+1);j=6;j++)
{
if(a[j]==a[i])
{ for(k=j;k<=6;k++)
a[k]=a[k+1];
}

}

for(i=0;i<7;i++)
printf("%c",a[i]);

}
return(0);
}

Is This Answer Correct ?    4 Yes 4 No

To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / hemalatha

import java.util.*;
class DupString
{
public static void main(String args[])
{
int i,j,len;
String s=new String();
Scanner sc=new Scanner(System.in);
System.out.println("Enter string");
s=sc.next();
len=s.length();
char[] s1=s.toCharArray();
for(i=0;i<len;i++)
{
for(j=i+1;j<len;j++)
{
if(s1[i]==s1[j])
{ if(s1[j]!='')
{
System.out.println(" "+s1[i]);
s1[j]='';
len--;
break;
}
}
}
}
}
}

Is This Answer Correct ?    0 Yes 0 No

To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / dave

void
rmdups(char *str)
{
char *sp;
for(sp = str; *sp; sp++)
{ char *lo, *hi;
for(lo = sp, hi=sp+1; *lo; hi++)
if(*hi != *sp)
*++lo = *hi;
}
}

Is This Answer Correct ?    4 Yes 5 No

To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / surya

#include<stdio.h>
#include<conio.h>
void main()
{
Char sen[40],sen1[40];
Int i,j;
Clrscr();
Printf("enter the sentence:
");
Gets(sen);
For(i=0,j=0;sen[i]!='';j++)
{
Sen1[j]=sen[i];
i++;
If(sen[i]==sen1[j])
{
sen1[j]=sen[i+1];
j=j-1;
}
}
sen1[j]='';
Puts(sen1);
Getch();
}

Is This Answer Correct ?    0 Yes 1 No

To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / avinash

#include<stdio.h>
void main()
{int i,j,n;
char a[]="avinash";


for(i=0;i=5;i++)
{

for(j=i+1;j=6;j++)
{
if(a[i]==a[j])
{a[j]=a[j+1];}


}

for(n=0;n<7;n++)
{printf("%c",a[n]);}

}
}

Is This Answer Correct ?    0 Yes 1 No

To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / lijun li

#include <stdio.h>

main(int argc, char **argv)
{
int i;
char *source = argv[1];
char *dest;
char *temp;

unsigned int bitmap[8] = {0,0,0,0,0,0,0,0};
unsigned char c;
unsigned int mask;

dest = (char*)malloc(strlen(source));
temp = dest;

printf("before %s\n", source);
i=0;
while(source[i])
{
c = source[i];
mask = 1 << (c % 32);

if ((bitmap[c/32] & mask) == 0)
{
*temp++ = source[i];
bitmap[c/32] |= mask;
}
i++;
}

*temp = '\0';

printf("after %s\n", dest);
}

Is This Answer Correct ?    15 Yes 22 No

To Write a C program to remove the repeated characters in the entered expression or in entered cha..

Answer / guest

#include <iostream.h>
int main()
{
char str[10],str1[10];
int i;
cout<<"enter the string";
cin>>str[];
for (i = 0;i<9;i++)
{
if (str[i] != str[i+1])
str1[i]=str[i];
}
cout<<str1[];
return 0;
}

Is This Answer Correct ?    8 Yes 28 No

Post New Answer

More C Code Interview Questions

main() { int i=-1; -i; printf("i = %d, -i = %d \n",i,-i); }

1 Answers  


How we print the table of 3 using for loop in c programing?

7 Answers  


Design an implement of the inputs functions for event mode

0 Answers   Wipro,


What is the hidden bug with the following statement? assert(val++ != 0);

1 Answers  


#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

1 Answers  






void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }

1 Answers  


int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }

1 Answers  


how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

0 Answers  


How can u say that a given point is in a triangle? 1. with the co-ordinates of the 3 vertices specified. 2. with only the co-ordinates of the top vertex given.

1 Answers  


What is data _null_? ,Explain with code when u need to use it in data step programming ?

0 Answers   Abbott,


why the range of an unsigned integer is double almost than the signed integer.

1 Answers  


Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };

1 Answers  


Categories