Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

1004


What is the use of f in c?

976


Explain what is the difference between functions getch() and getche()?

1049


What are the main characteristics of c language describe the structure of ac program?

1208


WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

2374


Explain argument and its types.

1058


What are global variables and explain how do you declare them?

1096


There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

1293


Implement bit Array in C.

1135


Which is best book for data structures in c?

1091


main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above

1084


What is main () in c language?

1129


write a proram to reverse the string using switch case?

2931


Why doesnt the call scanf work?

1189


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

2043