Question
to remove the repeated cahracter from the given caracter
array.
i.e..,
if the input is SSAD
output should of
SAD
Question Submitted By :: Selva909
I also faced this Question!!
Rank
Answer Posted By
Re: to remove the repeated cahracter from the given caracter
array.
i.e..,
if the input is SSAD
output should of
SAD
Answer
# 1
use lookup array
Umesh
Re: to remove the repeated cahracter from the given caracter
array.
i.e..,
if the input is SSAD
output should of
SAD
Answer
# 2
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;
Mohanraja [I-Net Solution]
Re: to remove the repeated cahracter from the given caracter
array.
i.e..,
if the input is SSAD
output should of
SAD
Answer
# 3
#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]);
}
Krishna
Re: to remove the repeated cahracter from the given caracter
array.
i.e..,
if the input is SSAD
output should of
SAD
Answer
# 4
#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]);
}
Krishna
Re: to remove the repeated cahracter from the given caracter
array.
i.e..,
if the input is SSAD
output should of
SAD
Answer
# 5
#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;
}
Welkin
Re: to remove the repeated cahracter from the given caracter
array.
i.e..,
if the input is SSAD
output should of
SAD
Answer
# 6
#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);
}
Vijay
Other C Code Interview Questions
Question Asked @ Answers main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513 HCL 1 void main()
{
int i=10, j=2;
int *ip= &i, *jp = &j;
int k = *ip/*jp;
printf(%d,k);
} 1 main()
{
int i=0;
while(+(+i--)!=0)
i-=i++;
printf("%d",i);
} 1 main()
{
extern i;
printf("%d\n",i);
{
int i=20;
printf("%d\n",i);
}
} 1 char *someFun1()
{
char temp[ ] = string";
return temp;
}
char *someFun2()
{
char temp[ ] = {s, t,r,i,n,g};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
} 1 How will you print % character?
a. printf(\%)
b. printf(\\%)
c. printf(%%)
d. printf(\%%) HCL 1 What are the following notations of defining functions known as?
i. int abc(int a,float b)
{
/* some code */
}
ii. int abc(a,b)
int a; float b;
{
/* some code*/
} 1 How to read a directory in a C program?
4 main()
{
int i=5,j=10;
i=i&=j&&10;
printf("%d %d",i,j);
} 1 Given an array of characters which form a sentence of words,
give an efficient algorithm to reverse the order of the words
(not characters) in it. Wipro 2 #include<stdio.h>
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
} 1 write a program to count the number the same
(letter/character foreg: 's') in a given sentence. 1 main()
{
int i = 100;
clrscr();
printf("%d", sizeof(sizeof(i)));
}
a. 2
b. 100
c. 4
d. none of the above HCL 2 main()
{
int i =10, j = 20;
clrscr();
printf("%d, %d, ", j-- , --i);
printf("%d, %d ", j++ , ++i);
}
a. 20, 10, 20, 10
b. 20, 9, 20, 10
c. 20, 9, 19, 10
d. 19, 9, 20, 10 HCL 1 #include<stdio.h>
main()
{
FILE *ptr;
char i;
ptr=fopen("zzz.c","r");
while((i=fgetch(ptr))!=EOF)
printf("%c",i);
} 1 #include<stdio.h>
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
} 1 How to return multiple values from a function?
4 main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
} 1 main()
{
char a[4]="HELL";
printf("%s",a);
} Wipro 1 void main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
} 1 For more C Code Interview Questions Click Here