#include <stdio.h>
#include <string.h>

int main() {
    int frq[256] = {0};
    char a[10] = "adarsh";

    for(int i=0;a[i]!='\0';i++){
        frq[a[i]]++;
    }

    for(int i=0;i<256;i++){
        if (frq[i]==1 || frq[i]==2) {
            printf("%c",i);
        }
    }
    
}
#if 0

int main() {
    int frq[256] = {0};//If we do not initialize the array, then the elements will
                    //contain garbage values which can lead to undefined behavior.
    char str[10] = {0};// do not type chapital letters for this
    
    if(scanf("%s",str)!=1){
        printf("input not found");
        return 1;
    }
    
    size_t len = strlen(str);
    
    for(int i=0;i<len;i++){
        frq[(int)str[i]]++;// imp frq[i]++ not inside
    }
    
    for(int i=0;i<256;i++){
        if(frq[i]==2){
            printf("%c",(char)i);//i has the ascii value of repiting char ex a=97
        }
    }
    return 0;
}

#endif
//If the sample rate is set to 256 samples per second, then each sample represents 
//a frequency of 1/256 Hz. This frequency resolution is often sufficient for many
//applications, and the use of a power of 2 makes it easier to perform efficient 
//processing operations on the sample data.

#if 0

Algorithm :

-> Ask the user to enter a string, read it and store it in a char array.

-> Create one int array of size 256 to hold the frequency of the characters.
Assign 0 to each element of the array. 

-> So, we have one integer array of size 256 with value 0 for each array position.

-> Our program will read the string and update this array.
The program will increment the ASCII position of a character in the array.
For example, if our string is AAA, it will increment the position 65 of the array
three times, because ASCII value of A is 65.

-> As explained above, scan the array one by one character and increment its
corresponding position in the array by 1.

-> After the input array is scanned, read the ASCII value and count holding array
one by one. If any value is more than 0, print out the result to the user.


#define T_alpa 256 //total no of ascii characters

int main() {
    char array1[100];
    int index,size;
    int frequency[T_alpa]={0};
    
    scanf("%s",array1);
    
    for(index=0;array1[index]!='\0';index++){ //appends the letters occurence in freq array 
        frequency[array1[index]]++;
    }
    
    for(index=0;index<=T_alpa;index++){
        if(frequency[index]==2){
            printf("%c",index);
        }
    }
}
#endif

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: