Sort by

recency

|

1176 Discussions

|

  • + 0 comments

    include

    include

    include

    include

    int main(void){ char* arr = (char*)malloc(1000*sizeof(char)); int *finalDigit = (int )calloc(1000, sizeof(int)); if (finalDigit == NULL) { printf("Memory allocation failed\n"); return 1; } scanf("%s", arr); int digit = (int *)malloc(1000*sizeof(int)); int len = strlen(arr), digitCount=0; for(int i = 0;i

  • + 0 comments
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include <stdlib.h>
    
    int main() {
    
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
        char s[1000];
        int freq[10] = {0}; 
    
        scanf("%[^\n]", s); 
        for (int i = 0; i < strlen(s); i++) {
            if (s[i] >= '0' && s[i] <= '9') {
                freq[s[i] - '0']++;
            }
        }
    
        for (int i = 0; i < 10; i++) {
            printf("%d ", freq[i]);
        }  
        return 0;
    }
    
  • + 1 comment
        char freq[10]={0}; // all index or Initialised with zero
        char *s = malloc (1024 * sizeof(char)); Allocating memory dynamically
        scanf("%[^\n]",s);
        for(int i = 0;i < strlen(s);i++)
        {
            if (s[i] >= '0' && s[i] <= '9'){ //checking the digit present or not char by char
                freq[s[i]-'0']++;
            }
        }
        for (int i = 0 ; i < 10; i++)
            printf("%d ",freq[i]);
        
        free(s);
    
  • + 0 comments

    int main() {

    char s[1000];
    scanf("%s",&s);
    int arr[100];
    for(int i=0;i<10;i++){
        int fre =0;     
        for(int j=0;j<strlen(s);j++){
            int num = s[j]-'0';
            if (num==i){
                fre=fre+1;
            } 
        }     
        arr[i]=fre;
    } 
    for (int i=0;i<10;i++){
        printf("%d ",arr[i]);
    }  
    return 0;
    

    }

  • + 0 comments

    include

    include

    include

    include

    int main() {

    char s[1000];
    scanf("%s",&s);
    int arr[100];
    for(int i=0;i<10;i++){
        int fre =0;     
        for(int j=0;j<strlen(s);j++){
            int num = s[j]-'0';
            if (num==i){
                fre=fre+1;
            } 
        }     
        arr[i]=fre;
    } 
    for (int i=0;i<10;i++){
        printf("%d ",arr[i]);
    }  
    return 0;
    

    }