Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language help! ! ! Define an integer array containing 10 elements, input 10 data through the keyboard and store it in the array, and then output it through the display
C language help! ! ! Define an integer array containing 10 elements, input 10 data through the keyboard and store it in the array, and then output it through the display

#include

#define N 10 //Define the number of array elements

main()

{

int a[N],i,max;

printf("Please enter %d array elements:\n",N);

scanf ("%d",&a[0]);

max=a[0];//Temporarily record the first value as the maximum value

for(i=1 ;i

{

scanf("%d",&a[i]);

if(a[i]>max)//Find the maximum value

max=a[i];

}

for(i=0; i

{

printf("%-5d",a[i]);//Output array elements

if(( i+1)%3==0)//3 elements per line

printf("\n");

}

printf(" \n");

printf("The maximum element is %d\n",max);//Output the maximum value

}