Type Here to Get Search Results !

Implement character count on given data

 a) Implement character count on given data

Algorithm for Character count

1. Start

2. Append DLE STX at the beginning of the string

3. Check the data if character is present; if character DLE is present in the string (example DOODLE) insert another DLE in the string (ex: DOODLEDLE)

4. Transmit DLE ETXat the end of the string

5. Display the string

6. Stop



PROGRAM:


#include<stdio.h>

 #include<string.h>

 main()

{

int i,j,k,l,count=0,n; char s[100],cs[50]; 

clrscr();

printf("\n ENTER THE BIT STRING:");

gets(s); 

n=strlen(s);

printf("\nTHE STRING IS\n"); 

for(i=0;i<n;)

{

if(s[i]==s[i+1])

{

count=2; i++; 

while(s[i]==s[i+1])

{ i++;

count++;

}

if(count>=5)

{

printf("$"); 

if(count<10) printf("0");

printf("%d%c",count,s[i]); 

i++;

}

else

{

for(j=0;j<count;j++)

 printf("%c",s[i]); 

i++;

}

}

 



else

{

printf("%c",s[i]);

 i++;

}

}

getch();

 }


INPUT/OUTPUT:


ENTER THE BIT STRING: 123AAAAAAAAAATYKKKPPPP

 P THE STRING IS

 123$10ATYKKK$05P


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Featured post

M

M