to remove the repeated cahracter from the given caracter
array.
i.e..,
if the input is SSAD
output should of
SAD

Answers were Sorted based on User's Feedback



to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD out..

Answer / vijay

#include<stdio.h>
main()
{
char arr[]="ssadddvhdfgiweuonbbnxjcusdfssd";
int i=0,j,k;
printf("Before string is %s \n",arr);
while(arr[i]!=0)
{
for(j=i+1;arr[j]!=0;j++)
{
if(arr[i]==arr[j])
{
for(k=j;arr[k]!=0;k++)
arr[k]=arr[k+1];
arr[k]='\0';
j--;
}
}
i++;
}
printf("After string is %s \n",arr);
}

Is This Answer Correct ?    3 Yes 0 No

to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD out..

Answer / umesh

use lookup array

Is This Answer Correct ?    0 Yes 0 No

to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD out..

Answer / krishna

#include<stdio.h>
void main()
{
char arr[]="aaadddssdsejskld";
int char_check=0;
int i,j;
char c;
clrscr();
while(arr[char_check])
{
c=arr[char_check];
i=j=char_check+1;
while(arr[i])
{
if(arr[i]!=c)
{
arr[j]=arr[i];
j++;
}
i++;
} arr[j]='\0';
char_check++;
}
for(i=0;arr[i]!='\0';i++)
printf (" \n%c\n " ,arr[i]);
}

Is This Answer Correct ?    0 Yes 0 No

to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD out..

Answer / krishna

#include<stdio.h>
void main()
{
char arr[]="aaadddssdsejskld";
int char_check=0;
int i,j;
char c;
clrscr();
while(arr[char_check])
{
c=arr[char_check];
i=j=char_check+1;
while(arr[i])
{
if(arr[i]!=c)
{
arr[j]=arr[i];
j++;
}
i++;
} arr[j]='\0';
char_check++;
}
for(i=0;arr[i]!='\0';i++)
printf (" \n%c\n " ,arr[i]);
}

Is This Answer Correct ?    0 Yes 1 No

to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD out..

Answer / welkin

#include<stdio.h>
int main()
{
int i=0,j,x=-1;
char str[10],temp,temp1,buff[10];
printf("\nEnter the string ");
scanf("%s",str);
while((temp=str[i])!=NULL)
{
for(j=0;j<=x;j++)
{
temp1=buff[j];
if(temp==temp1)
{
break;
}
}
if(j>x)
buff[++x]=temp;
i++;
}
buff[++x]='\0';
printf("\n%s",buff);
return 0;
}

Is This Answer Correct ?    0 Yes 1 No

to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD out..

Answer / mohanraja

string s,str;
s = string.Empty;
str = this.txtString.Text;
foreach (char c in str)
{
if (s.IndexOf(c) == -1)
{
s = s + c.ToString();
}
}
this.label1.Text = s;

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Code Interview Questions

Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

16 Answers   Aricent, Cisco, Directi, Qualcomm,


Write a program that reads a dynamic array of 40 integers and displays only even integers

2 Answers  


Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);

1 Answers  


main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); } int i;

1 Answers  


Cluster head selection in Wireless Sensor Network using C programming language.

0 Answers  






main ( ) { static char *s[ ] = {“black”, “white”, “yellow”, “violet”}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf(“%s”,*--*++p + 3); }

1 Answers  


Is this code legal? int *ptr; ptr = (int *) 0x400;

1 Answers  


union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); } a. 4, 4, 4 b. 40, 4, 4 c. 1, 100, 1 d. 40 400 4

3 Answers   HCL,


can u give me the c codings for converting a string into the hexa decimal form......

1 Answers  


void main() { static int i; while(i<=10) (i>2)?i++:i--; printf(“%d”, i); }

2 Answers  


#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  


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  


Categories