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

int i, mot, caractere;
char ch[100];
int main() {
    
    printf("Entrer la chaine de caracteres : ");
    gets(ch);

   // Calcul du nombre de caractères
    caractere = 0;
    for (i = 0; ch[i] != '\0'; i++) {
        if (ch[i] != ' ' && ch[i] != '\n' && ch[i] != '\t') {
            caractere++;
        }
    }
   
   
   // Calcul du nombre de mots
   mot = 1;
   for (i = 0; ch[i] != '\0'; i++) {
        if (ch[i] == ' ' || ch[i] == '\n' || ch[i] == '\t') {
            mot++;
        }
    }
    printf("Le nombre de mots dans la chaine de caracteres est : %d\n", mot);
     printf("Le nombre de caracteres dans la chaine de caracteres est : %d", caractere);
    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter