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

All the combinations of prime numbers whose sum gives 32

1 Answers   HHH,


const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); } a. 0 b. 2 c. 4 d. none of the above

1 Answers   emc2, HCL,


main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024

2 Answers   HCL,


Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally, print out how many zeros and ones in the diagonal.

2 Answers  


main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }

1 Answers   TCS,






Find your day from your DOB?

15 Answers   Accenture, Microsoft,


#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, line %d \n",#cond,\ __FILE__,__LINE__), abort()) void main() { int i = 10; if(i==0) assert(i < 100); else printf("This statement becomes else for if in assert macro"); }

1 Answers  


plz tell me the solution.......... in c language program guess any one number from 1 to 50 and tell that number within 8 asking question in yes or no...............

2 Answers   Wipro,


main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(“%d” ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(“%d ” ,*p); p++; } }

1 Answers  


main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }

3 Answers  


Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.

0 Answers  


Categories