Thursday, September 25, 2014

WAP to find the average expenditure of a company for each month of each year and average over the range of years specified. Use arrays to construct a table, display the table of expenditure and find the sum and average.

#include
#include
void main()
{
            int i,n,j,b=0,a[12][12],c=0,d=0,e=0;
            clrscr();
            printf ("\t************* EXPENDITURE OF THE COMPANY **************\t");
            printf ("\n How many years???");
            scanf ("\t %d",&n);
            for (i=1;i
            {
                        printf ("\n \n");
                        printf ("\n ----For the %d year----\n \n",i);
                        b=0;
                        for (j=1;j<13 j="" o:p="">
                        {
                                    printf ("Enter the expenditure for %d month::Rs.\t",j);
                                    scanf ("\t %d",&a[i][j]);
                                    b=b+a[i][j];
                        }
                        printf ("\n Total Expenditure of the whole year:Rs.\t%d",b);
                        c=b/12;
                        printf ("\n Average Expenditure of the year:Rs.\t%d",c);
                        e=e+b;
            }
            printf ("\n \n");
            printf ("\n Total Expenditure of %d years:Rs.\t%d",n,e);
            d=e/n;
            printf ("\n Average Expenditure of %d years:Rs.\t%d",n,d);
            getch();

}

No comments:

Post a Comment