I have this program that I am supposed to have a program that writes the sum and how many quarters. I am mainly just wondering how to find the average sales per quarter. Code below
#include<stdio.h>
int main()
{ int n,sum=0,sales,i; 2
2
printf("How many years do you wish to average ");
scanf("%d",&n);
if(n==0)
{
printf("Year must be at least one \n and renter ");
scanf("%d",&n);
}
for( i=1;i<=n;i++)
{
printf("year %d\n",i);
for(int j=1;j<=4;j++)
{
printf(" Sales amount of quarter %d\t",j);
scanf("%d",&sales);
if(sales<0)
{
printf("Sales amount should be greater than zero");
}
sum=sum+sales;
}
}
printf("Over a period %d quarters, %d\t",(i-1)*4,sum);