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);
main ()
ReplyDelete{
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;
}
c programming code snippets
ReplyDeletePrint to a file using the fprintf function