1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
int main(int argc, char *argv[])
{
int i;
char nom_produit[20];
float prix_produit[5];
float prix_moyen;
float prix_min;
void moy_min_prix (float prix[5], float *pprix_moyen,float *pprix_min);
printf ("saisir le nom du produit : ");
scanf("%s",nom_produit);
for (i=0;i<5;i++)
{
printf ("donner le prix du %s dans le magasin %d : ",nom_produit,i+1);
scanf ("%f",prix_produit);
}
moy_min_prix ( &prix_produit[5], &prix_moyen, &prix_min);
printf("Le prix moyen du %s est : %2f",nom_produit, &prix_moyen);
printf ("\nLe prix le plus bas du %s est : %2f\n",nom_produit,&prix_min);
system("PAUSE");
return 0;
}
void moy_min_prix( float prix[5],float *pprix_moyen,float *pprix_min){
int j;
float somme=0;
for (j=0;j<5;j++)
somme=somme+prix[j];
*pprix_moyen=somme/5;
*pprix_min=prix[0];
for (j=1;j<5;j++)
if (prix[j]<*pprix_moyen);
*pprix_min=prix[j];
}
; |
Partager