Monday, February 28, 2011

Arrays

The daily maximum temperatures recorded in 10 cities during the month of January (for 10 days) have been tabulated. Write a program to read the table elements into a two-dimensional array temprature, and to find the city and day corresponding to
(a) the highest temperature and
(b) the lowest temperature.

#include <stdio.h>
#define Day 5
#define City 10
void main()
{
int i,j;
float value[62][20];
clrscr();
printf("Enter the temperature of 10 cities in january month\n");
for(i=1;i<=Day;i++)
{
for(j=1;j<=City;j++)
scanf("%f",&value[i][j]);
}
printf(" City\n");
printf("Day ");
for(j=1;j<=City;j++)
printf("%d     ",j);
putchar('\n');
for(i=1;i<=Day;i++)
{
printf("%d ",i);
for(j=1;j<=City;j++)
printf("%5.2f ",value[i][j]);
putchar('\n');
}
getch();
}

No comments:

Post a Comment