Professional Documents
Culture Documents
Assingment 2
Assingment 2
h>
#define size 7
int main(void)
{
int list[size] = { 0 }, i, sum = 0, max, min, search_key, found = 0, j, temp;
}
printf("The sum of all the values are %d\n", sum);
max = list[0];
for (i = 1; i < size; i++)
{
if (list[i] > max)
max = list[i];
}
min = list[0];
for (i = 1; i < size; i++)
{
if (list[i] < min)
min = list[i];
}
printf("The highest value in the list is %d\n", max);
printf("The lowest value in the list is %d\n", min);
if (found == 0)
printf(" Sorry %d is not in the list\n", search_key);
{
for (j = i + 1; j < size; j++)
{
if (list[i] > list[j])
{
temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
}
printf("\nElements of array in sorted ascending order: \n");
for (int i = 0; i < 5; i++)
printf("%d ", list[i]);
printf("\n");
return(0);
}