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

#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }

3 Answers  


main() { main(); }

1 Answers  


main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


create a login program that ask username and password. if you input username or password 3 times wrong, the program will terminate else the program will prompt a message "congratulations"

2 Answers  


main() { char *p; p="%d\n"; p++; p++; printf(p-2,300); }

1 Answers  






How to return multiple values from a function?

7 Answers  


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

2 Answers   Adobe, CSC,


what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);

2 Answers  


How do you sort a Linked List (singly connected) in O(n) please mail to pawan.10k@gmail.com if u can find an anser...i m desperate to knw...

6 Answers   Microsoft, MSD, Oracle,


main() { static int var = 5; printf("%d ",var--); if(var) main(); }

1 Answers  


1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.

3 Answers  


main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }

1 Answers  


Categories