Answer to Question #327147 in C for Sunny

Question #327147

A data compression software utilizes various steps to compress a string of data. One of the steps involves finding the count of characters that are not repeated on the string





1
Expert's answer
2022-04-11T12:13:05-0400
#include <stdio.h>
#include <string.h>

int main()
{
    char str[250];
    char rep[250];
    int i, j, len, check, cnt_not_rep, i_rep, temp;    
    printf("Enter string: ");
    scanf("%[^\n]", str);        
    cnt_not_rep = 0;
    i_rep = 0;
    len = strlen(str);
    for (i = 0; i < len-1; i++)
    {                
        check = 0;
        for (j = i+1; j < len; j++)
        {
            if(str[i] == str[j])
            {
                check = 1;
                i_rep++;
                rep[(i_rep - 1)] = str[i];
            }
        }
        if (check == 0)
            {
                temp = 0;
                for (j = 0; j < i_rep; j++)
                    if (rep[j] == str[i])
                        temp = 1;
                if (temp == 0)
                    cnt_not_rep++;
            }
    }
        check = 0;
        for (j = 0; j < i_rep; j++)
            if (rep[j] == str[len-1])
                check = 1;
        if (check == 0)
            cnt_not_rep++;
    printf("\nCount of characters that are not repeated: %d\n", cnt_not_rep);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS