#include <stdio.h>
struct data
{
int channel,time,bit_depth;
float rate,audio_size;
};
void get_input(struct data record[],int amount);
void get_input(struct data record[],int amount)
{
int i;
for(i=0;i <amount ; i++)
{
printf("Record #%d\n",i+1);
printf(" Enter channel - [1] Mono [2] Stereo : ");
scanf("%d",&record[i].channel);
printf(" Enter sampling rate (Hz) : ");
scanf("%f",&record[i].rate);
printf(" Enter time (seconds) : ");
scanf("%d",&record[i].time);
printf(" Enter audio bit depth (bits) : ");
scanf("%d",&record[i].bit_depth);
record[i].audio_size=record[i].channel*record[i].rate*record[i].time*(record[i].bit_depth/8);
}
}
void display(struct data record[],int amount);
void display(struct data record[],int amount)
{
int i;
printf("Channel Sampling Rate Time Bit Depth Audio Size\n");
printf("----------------------------------------------------\n");
for(i=0;i<amount;i++)
printf("%-8d %-14.2f %-5d %-11d %-.2f\n",record[i].channel,record[i].rate,record[i].time,record[i].bit_depth,record[i].audio_size);
}
main()
{
int amount=0;
struct data record[0];
printf("==============================\n");
printf("= CALCULATE AUDIO DATA SIZE = \n");
printf("==============================\n");
printf("How many audio records to process? ");
scanf("%d",&amount);
get_input(record,amount);
printf("\n:: AUDIO REPORT ::\n\n");
display(record,amount);
system("PAUSE");
}