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



Write a C program to remove the repeated characters in the entered expression or in entered charact..

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

Write a C program to remove the repeated characters in the entered expression or in entered charact..

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

Write a C program to remove the repeated characters in the entered expression or in entered charact..

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

Post New Answer

More C Interview Questions

HOW CAN ADD OUR FUNCTION IN LIBRARY.

5 Answers  


what defference between c and c++ ?

6 Answers  


A set of N billiard balls are set on a one-dimensional table. The table is 1 meter long, set north-south with two pockets at either side. Each ball has zero width and there is no friction so it is moving with a fixed velocity of either northward or southward and bounces back in a perfect elastic collision from other balls it encounter on its way (or drop into one of the pockets). Your job is to keep track of the balls movements. Task Please write a program that gets the initial place, speed and direction of all the balls and gives the position of a specific ball after t seconds. Input The first line contains the number of scenarios. Each one of the other lines in the input contains a scenario: The first number, N, is the number of balls; followed by N pairs of numbers: the distance in centimeters from the south end of the table and the speed (positive speed meaning it moves northward); the last two numbers are the number i of the target ball you should track and the time T in seconds. Output The output is a single number for each line which is the place (distance in centimeters from the south end of the table) of the tracked ball after T seconds. Note: There is no new line character at the end of the result. Sample Input 5 1 50 1 1 1000 1 50 1 1 6 1 60 -2 1 6 2 10 1 95 -1 2 30 2 10 1 95 -1 2 60 Sample Output 100 56 48 65 70

0 Answers  


Given a number N, product(N) is the product of the digits of N. We can then form a sequence N, product(N), product(product(N))… For example, using 99, we get the sequence 99, 99 = 81, 81 = 8. Input Format: A single integer N Output Format: A single integer which is the number of steps after which a single digit number occurs in the sequence. Sample Test Cases: Input #00: 99 Output #00: 2 Explanation: Step - 1 : 9 * 9 = 81 Step - 2 : 8 * 1 = 8 There are 2 steps to get to this single digit number. Input #01: 1137638147

2 Answers  


What is a macro in c preprocessor?

0 Answers  






What is echo in c programming?

0 Answers  


What is difference between structure and union in c programming?

0 Answers  


How many types of sorting are there in c?

0 Answers  


#include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain &#1567;&#1567;&#1567;

4 Answers  


Which is more efficient, a switch statement or an if else chain?

0 Answers  


please tell me the logic for this C program : INPUT (string):ABCD OUTPUT :BCDA CDAB DABC

2 Answers   Mphasis,


What is the purpose of sprintf?

0 Answers  


Categories