Tp1_1.c 1.05 KB
#include <stdio.h>


int chiffre(char ch){
    if ((ch >= '0') && (ch <= '9')){
        return 1;
    }else{
        return 0;
    }
}

int minuscule(char ch){
    if ((ch >= 'a') && (ch <= 'z')){
        return 1;
    }else{
        return 0;
    }
}


int majuscule(char ch){
    if ((ch >= 'A') && (ch <= 'Z')){
        return 1;
    }else{
        return 0;
    }
}


void analysePhrase(int* nbChar, int* nbChiffre, int* nbMin, int * nbMaj){
     
    char c;
    scanf("%c",&c);

   
    while(c!='.'){
        if(chiffre(c)==1){
            *nbChiffre = *nbChiffre+1;
        }else if(minuscule(c)==1){
            *nbMin=*nbMin+1;
        }else if(majuscule(c)==1){
            *nbMaj=*nbMaj+1;
        }
    scanf("%c",&c);
    *nbChar=*nbChar+1;
    }
   
}
    


int main(){
    int nbChar=0,nbChiffre=0,nbMin=0, nbMaj =0;
    printf("Char: %d Chiffre: %d nbMin: %d nbMaj: %d\n",nbChar,nbChiffre,nbMin, nbMaj);
    analysePhrase(&nbChar,&nbChiffre,&nbMin,&nbMaj);
    printf("Char: %d Chiffre: %d nbMin: %d nbMaj: %d\n",nbChar,nbChiffre,nbMin, nbMaj);
    return 0;
}