C Code 7 _ To print the unique characters from a string of consecutive repeating characters in reverse order



C Code 7 _ To print the unique characters from a string of consecutive repeating characters in reverse order


The aim of the program is to print all the repeating characters from a string that has consecutive repeating characters in reverser order.

 example:  
   input string : hello
   output string: oleh

Program:



#include<stdio.h>
#include<string.h>
int main()
{
    char a[100],b[100],c[100];
    int i,j=1,len1,len2,lref;
    printf("Enter the string : ");
    scanf("%s",a);
    len1=strlen(a);
    printf("\nLength of entered string : %d",len1);
    b[0]=a[0];
    for(i=1;i<len1;i++)
    {
          if(a[i]!=a[i-1])
          {
                b[j]=a[i];
                j=j+1;
          }
    }
    b[j]='\0';
    printf("\nThe unique string : %s ",b);
    len2=strlen(b);
    lref=len2-1;
    printf("\nLength of unique string : %d",len2);
    for(i=0;i<len2;i++)
    {
        c[i]=b[lref];
        lref=lref-1;
    }
    c[len2]='\0';
    printf("\nThe result : %s",c);
    getch();
    return 0;
}




Output:






Thank you ...
Previous Post
Next Post
Related Posts

0 comments:

Popular Posts