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
Answer / balaji ganesh
#include<stdio.h>
main()
{
char s[50];
int i=0,j;
printf("enter character string:");
while((s[i]=getchar())!='\n')
{
for(j=0;j<i;j++)
if(s[j]==s[i])
i--;
i++;
}
printf("after removing the duplicates the string is:");
for(j=0;j<i;j++)
printf("%c",s[j]);
}
| Is This Answer Correct ? | 10 Yes | 4 No |
Answer / nallavelli srinivas
MAIN()
{ int lsu=0;
char name[50];
pf("enter the string");
sf("%S",name);
printf(name[0]);
while(name[i]!='\0')
{
if(name[i]!=lsu){pf(name[i]);
lsu=name[i];
}
}
}
| Is This Answer Correct ? | 1 Yes | 5 No |
Answer / sowjanya
void main()
{
int rep=0;
char ch,str[50];
printf("enter the string:"):
scanf("%s",str);
printf("enter the character:");
scanf("%s",ch);
for(int i=0;str[i]!='/0';i++)
{
if(str[i]==ch)
{
rep++;//to count character
str[i]=' ';//to delete the duplicate
}
}
printf("the character is repeated %d times",rep);
printf("now all duplicates are deleted.");
}
| Is This Answer Correct ? | 5 Yes | 13 No |
What are identifiers and keywords in c?
int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of arr[]
What is the difference between null pointer and the void pointer?
#include<stdio.h> int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20
When the macros gets expanded?
can we declare a function inside the structure? ex: struct book { int pages; float price; int library(int,float); }b; is the above declaration correct? as it has function declaration?
What is the role of && operator in a program code?
What is difference between stdio h and conio h?
How does the assert() function work?
Why is this loop always executing once?
Difference between Function to pointer and pointer to function
main() { int age; float ht; printf("Enter height and age"); scanf("%d%d",&height,&age); if((age<=20)&&(ht>=5)) {printf("She loves you");} else {printf("She loves you");} }