{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Serie6_corrige - Série 6 corrigé Exercice...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Série 6 corrigé Exercice 1 #include <stdio.h> int main(int argc, char **argv) { char voy [6] = {'a','e','i','o','u','y'}; int compte[6]; int i; char c; for (i=0; i<6; i++) compte [i]=0; printf("entrez un texte de votre choix: \n"); do { scanf ("%c",&c); for (i=0; i<6; i++) if (c== voy[i]) compte[i]=compte[i]+1; } while (c!='\n'); printf("Votre texte contient : \n"); for (i=0; i<6; i++) printf("%d fois la lettre %c\n",compte[i],voy[i]); return 0; } Exercice 2 - Factorielle Avec while : #include <stdio.h> int main(int argc, char **argv) { int n; int resultat = 1; int original; printf("Entrez un entier positif dont vous desirez calculer la factorielle: "); scanf("%d",&n); original = n; while (n > 1) { resultat = resultat * n; n--; } printf("%d ! = %d\n",original,resultat); return 0; } avec FOR : #include <stdio.h> int main(int argc, char **argv) { int n; int resultat = 1; int original; printf("Entrez un entier positif dont vous desirez calculer la factorielle: "); scanf("%d",&n); original = n; for (;n> 1;n--) // ici on n’initialise pas car on prend la valeur de n { resultat = resultat * n; } printf("%d ! = %d\n",original,resultat); return 0; } Exercice 3 - Note 1) #include <stdio.h> #include <stdio....
View Full Document

{[ snackBarMessage ]}

Page1 / 5

Serie6_corrige - Série 6 corrigé Exercice...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online