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

find simple interest & compund interest

2 Answers  


what is oop?

3 Answers  


Find the largest number in a binary tree

7 Answers   Infosys,


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

1 Answers  


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

0 Answers  






how can u draw a rectangle in C

53 Answers   Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,


main() { char *p; p="Hello"; printf("%c\n",*&*p); }

1 Answers  


void main() { int x,y=2,z; z=(z*=2)+(x=y=z); printf("%d",z); }

4 Answers  


Find your day from your DOB?

15 Answers   Accenture, Microsoft,


How to palindrom string in c language?

6 Answers   Google,


Write a program to print a square of size 5 by using the character S.

6 Answers   Microsoft,


3) Int Matrix of certain size was given, We had few valu= es in it like this. =97=97=97=97=97=97=97=97=97=97=97 1 = | 4 | | 5 | &= nbsp; | 45 =97=97=97=97=97=97=97=97=97=97=97 &n= bsp; | 3 | 3 | 5 | = | 4 =97=97=97=97=97=97=97=97=97=97=97 34 |&nbs= p; 3 | 3 | | 12 | &= nbsp; =97=97=97=97=97=97=97=97=97=97=97 3 | &nbs= p; | 3 | 4 | = | 3 =97=97=97=97=97=97=97=97=97=97=97 3 | = ; | | | = ; 3 | =97=97=97=97=97=97=97=97=97=97=97 &= nbsp; | | 4 | = ; | 4 | 3 We w= ere supposed to move back all the spaces in it at the end. Note: = If implemented this prog using recursion, would get higher preference.

0 Answers   RoboSoft,


Categories