#include <stdio.h> int main() { int array [10]; int sum = 0; int i; int smallest, largest; int destinationArray [10]; float ave; printf("Enter 10 integer:\n "); for (i=0; i<10; i++) { printf ("Enter integer %d:", i + 1); scanf ("%d", &array[i]); } printf ("Integer you've enter: "); for (i=0; i<10; i++){ printf ("%d", array[i]); sum+=array[i]; } printf("\n"); ave = (float)sum/10; printf("The sum of integer: %d\n", sum); printf ("The average of the integer: %lf\n ", ave); printf ("\nThe odd number are: \n"); for (i=0; i<10; i++) { if (array[i] % 2 != 0) { printf ("%d", array[i]); } } printf ("\nThe even number are: \n"); for (i=0; i<10; i++) { if (array[i] % 2 == 0) { printf ("%d", array[i]); } } smallest = array[0]; for (i=0; i<10; i++){ if (array[i] < smallest){ smallest = array[i]; } } printf ("\nThe smallest element: %d\n", smallest); largest = array[0]; for (i=0; i<10; i++){ if (array[i] > largest){ largest = array[i]; } } printf ("The largest element: %d\n", largest); for (i=0; i< 10; i++) { destinationArray[i] = array[i]; } printf ("Copy: \n "); for (i=0; i< 10; i++) { printf ("%d", destinationArray[i]); } printf ("\n"); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter