Serie6_corrige - Série 6 corrigé Exercice 1 #include

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 DocumentRight 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

This note was uploaded on 10/08/2010 for the course CH 3123 taught by Professor -- during the Fall '08 term at Ecole Polytechnique Fédérale de Lausanne.

Page1 / 5

Serie6_corrige - Série 6 corrigé Exercice 1 #include

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

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