C Program
#include <stdio.h>
#include <string.h>
int main() {
int n;
printf("Enter the number of bits: ");
scanf("%d", &n);
char bits[n+1];
printf("Enter the bits: ");
scanf("%s", bits);
int count = 0;
int zeroFound = 0;
for (int i = 0; i < strlen(bits); i++) {
if (bits[i] == '1') {
count++;
if (count == 5 && zeroFound) {
printf("111110");
count = 0;
}
} else {
for (int j = 0; j < count; j++) {
printf("1");
}
printf("0");
count = 0;
zeroFound = 1;
}
}
for (int j = 0; j < count; j++) {
printf("1");
}
if(zeroFound){
printf("\nstuffed!!\n");
}else{
printf("\nno need to stuff!!\n");
}
return 0;
}
Output

