#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
int main (int argc, char *argv[] )
{
?? ?int i;
?? ?FILE *fp;
?? ?float a[SIZE];
?? ?double sum = 0.0;
?? ?
?? ?if (argc > 2)
?? ??? ?exit(EXIT_FAILURE);
?? ?else if(argc == 2)?
?? ?{
?? ??? ?if ((fp = fopen (argv[1],"w")) == NULL)
?? ??? ??? ?exit (EXIT_FAILURE) ;
?? ??? ??? ?for(i = 0,sum=0;i<SIZE;i++)
?? ??? ??? ?{
?? ??? ??? ??? ?scanf("%f",&a[i]);
?? ??? ??? ??? ?sum += a[i];
?? ??? ??? ??? ?fprintf(fp,"a[%d]=%f\n",i,a[i]);?? ?
?? ??? ??? ??? ?fprintf(fp,"Averagea[%d]=%lf\n",i,sum/(i+1));?? ??? ??? ?
?? ??? ??? ?}
?? ??? ?fclose (fp) ;
?? ?}
?? ?else if(argc==1)?
?? ??? ?for(i = 0,sum=0;i<SIZE;i++)
?? ??? ?{
?? ??? ??? ?scanf("%f",&a[i]);
?? ??? ??? ?printf("i[%d]=%f\n",i,a[i]);
?? ??? ??? ?sum += a[i];
?? ??? ??? ?printf("Average[%d]=%f\n",i,sum/(i+1));
?? ??? ?}
?? ?return 0;
}
?