Tutorial 11
01.Find the minimum and maximum of sequence of 10 numbers stored in array.
#include<stdio.h>
int main ()
{
int num[10] ={5,4,8,20,9,2,24,5,1,2};
int i;
int max=0;
int min=0;
for (i=0;i<10;i++)
{
if (max < num[i])
{
max = num[i];
}
if (min> num[i])
{
min = num[i]
}
}
printf("Maximum number is: %i", max);
printf("Minimum number is %i", min);
return 0;
}
02.Find the total and average of a sequence of 10 numbers stored in array.
#include<stdio.h>
int main()
{
int num[10] ={5,4,8,20,4.56,2,24,5,1,2};
int i;
float total = 0;
float avg = 0;
for (i=0;i<10;i++)
{
total = total + num[i];
}
avg = total / 10;
printf("Total is : %.2f",total);
printf("Average is : %.2f",avg);
return 0;
}