Write a program to find a maximum and minimum element in an array of 10 numbers php
Answers
Answered by
1
#include<stdio.h>
int main ()
{
int i; int a[10] =
{
10, 55, 9, 4, 234, 20, 30, 40, 22, 34 };
int max = a[0]; int min = a[0]; for (i = 0; i < 10; i++)
{ if (a[i] > max) { max = a[i]; } else if (a[i] < min) { min = a[i]; }
}
printf
("Maximum element in an array : %d\n", max);
printf ("Minimum element in an array : %d\n",
min); return 0; }
int main ()
{
int i; int a[10] =
{
10, 55, 9, 4, 234, 20, 30, 40, 22, 34 };
int max = a[0]; int min = a[0]; for (i = 0; i < 10; i++)
{ if (a[i] > max) { max = a[i]; } else if (a[i] < min) { min = a[i]; }
}
printf
("Maximum element in an array : %d\n", max);
printf ("Minimum element in an array : %d\n",
min); return 0; }
Similar questions
Biology,
1 year ago
Math,
1 year ago
Social Sciences,
1 year ago
English,
1 year ago
Physics,
1 year ago