write a c program to remove all the duplicate characters in a
string and replace with single character?
ex:-input- AAABBBCCC
output- ABC
Answer Posted / vikas
// removal of duplicate character form a given string
#include <string.h>
#include <stdio.h>
int main()
{
char os[30];
char ds[20];
int i=0,j=0, c;
printf("Enter string\n");
while ((c = getchar()) != '\n')
os[i++] = c;
os[i] = '\0';
ds[0] =os[0];
ds[1] = '\0';
i = 1;
while ( os[i] != '\0'){
j = 0;
while (ds[j] != '\0') {
if (ds[j] == os[i])
break;
else
j++;
}
if (ds[j] == '\0') {
ds[j] = os[i];
ds[++j] = '\0';
}
i++;
}
printf("Original string = %s\n", os);
printf("modified string = %s\n", ds);
return 0;
}
Is This Answer Correct ? | 13 Yes | 4 No |
Post New Answer View All Answers
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
How many keywords are there in c?
What is pointer to pointer in c language?
program to convert a integer to string in c language'
What are the types of pointers in c?
Where local variables are stored in c?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
What is FIFO?
What is the use of getchar functions?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
How is a macro different from a function?
What is the Purpose of 'extern' keyword in a function declaration?
in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above
a c code by using memory allocation for add ,multiply of sprase matrixes
What is a floating point in c?