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() { char name[10],s[12]; scanf(" \"%[^\"]\"",s); } How scanf will execute?

2 Answers  


main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }

1 Answers  


main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }

2 Answers   Adobe, CSC,


main() { int i=5; printf(ā€œ%dā€,i=++i ==6); }

1 Answers  


typedef struct error{int warning, error, exception;}error; main() { error g1; g1.error =1; printf("%d",g1.error); }

1 Answers  






main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }

1 Answers  


plz send me all data structure related programs

2 Answers  


main() { int i = 257; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }

1 Answers   CSC,


main() { int i=10; i=!i>14; Printf ("i=%d",i); }

1 Answers  


main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


Under linux environment can u please provide a c code for computing sum of series 1-2+3-4+5......n terms and -1+2-3+4-5...n terms..

2 Answers  


What is your nationality?

1 Answers   GoDB Tech,


Categories