Page 807 - IT2
P. 807

Exercice3 : (6 pts)

               Ecrire un algorithme  qui permet de calculer la somme suivante :

               S=1 ! + 2!+ 3! +……….. + n!  (n saisi par l’utilisateur)

               Indication : on suppose que vous disposez d’une fonction fact(n) pour calculer la factoriel.



               PARTIE 2 : PRATIQUE (80 pts)


               Dossier1 : LANGAGE DE PROGRAMMATION STRUCTUREE (70 pts)

               Exercice1 : (14 pts)
               Soit le programme C suivant :



                 #include<stdio.h>
                 #include<string.h>
                 main()
                 {
                  FILE* f1;
                  FILE* f2;
                  int matricule ;
                  char nom[20];
                 float salaire ;
                  f1=fopen("fichier1.txt","r");
                  f2=fopen("fichier2.txt","w");
                  if(f1!=NULL && f2!=NULL)
                  {
                     while(!feof(f1))
                     {
                       fscanf(f1,"%d\t%s\t%f\n",&matricule,nom,&salaire);

                       if(matricule%10!=8)
                         fprintf(f2,"%d\t%s\t%.0f\n",matricule,nom,salaire);
                     }
                     fclose(f1);
                     fclose(f2);
                  }
                  else
                      printf("problème d'ouverture de fichier");
                  }

               1) Que signifie  while( !feof(f1))? (3 pts)
               2) Que signifie   if(matricule%10!=8) ? (3 pts)
               3) Le fichier « fichier1.txt » contient le texte suivant :






                       Filière                Epreuve                Session
                                                                                             3/7
                    DI(CDS de 1 à 2)        Synthèse V2            Juillet 2016
                                        www.itlearning-settat.com

                                  Email: admission@itlearning-settat.com

                                                  Tél.:0661077812
   802   803   804   805   806   807   808   809   810   811   812