I need a C program that will do this Tsunami analysis Downlo
I need a C program that will do this
Tsunami analysis Download the attached file that contains data for noteworthy tsunamis. Each record has the following fields: month, day, year, fatalities, wave height in meters, location. Write a program that reads the data and prints out a report containing the following the maximum wave height in feet the average wave height in feet all the locations of the tsunamis that were less than the average wave heightSolution
#include<stdio.h>
#include<conio.h>
//assume the data is in file tsunami.txt
void main()
{
FILE *fp;
char names[10][100];
int dd,mm,yy,c;
float h[10];
int sum=0;
float max=0;
float avg;
int i;
clrscr();
fp = fopen(\"tsunami.txt\", \"r\");
for(i=0;i<10;i++)
{
fscanf(fp,\"%d%d%d%d%f%s\",&mm,&dd,&yy,&c,&h[i],names[i]);
if(h[i]>max)
max=h[i];
sum+=h[i];
}
avg = (float)sum / 10.00;
printf(\"\ Maximum wave height: %f\", max);
printf(\"\ Average wave height = %f\",avg);
printf(\"\ \ Locations with less than average wave height:\ \");
for(i=0;i<10;i++)
{
if(h[i]<avg)
printf(\"%s\ \",names[i]);
}
fclose(fp);
getch();
}
