/*
* Your name:
*
* Your student ID:
*
*/
#include
#define ASIZE 20
main()
{
int a[ASIZE], b[ASIZE], c[ASIZE];
int i;
printf("Name: your name goes here\n");
printf("ID: your student ID goes here\n");
/* read in 20 integers and stored them in a[] */
for(i=0; i= 0\n");
/* insert your code here */
printf("\nProblem 6: print a[i] where a[i] is odd\n");
/* insert your code here */
printf("\nProblem 7: print out the sum of all a[i]'s\n");
/* insert your code here */
printf("\nProblem 8: print out the sum of all a[i]'s where a[i] is odd\n");
/* insert your code here */
printf("\nProblem 9: print a[i] where a[i] is a multiple of 5\n");
/* insert your code here */
printf("\nProblem 10: find the largest a[i] and print it out\n");
/* insert your code here */
printf("\nProblem 11: find the smallest a[i] and print both i and a[i]\n");
/* insert your code here */
printf("\nProblem 12: print out the number of times 5 appears in array\n");
/* insert your code here */
printf("\nProblem 13: print out the number of positive and negative numbers in a\n");
/* insert your code here */
printf("\nProblem 14: print out the number of a[i]'s that are both positive and a multiple of 5\n");
/* insert your code here */
printf("\nProblem 15: print out those a[i]'s that are multiples of 3 or 5, but not both\n");
/* insert your code here */
printf("\nProblem 16: copy array a into b but in reverse order, then redo Problem 11 on b\n");
/* insert your code here */
printf("\nProblem 17: \ncopy each a[i] to array c as follows: \n");
printf(" if a[i] is positive, put it in the leftmost available entry in c,\n");
printf(" otherwise, put it in the rightmost available entry in c\n");
printf("print c out at the end\n");
/* insert your code here */
}
/* The following is a test run of the program with input
1 -2 3 -4 5 -6 7 -8 9 -10 0 3 5 7 9 11 13 15 17 19
Problem 1: print array a in sequence
1 -2 3 -4 5 -6 7 -8 9 -10 0 3 5 7 9 11 13 15 17 19
Problem 2: print array a in reverse order
19 17 15 13 11 9 7 5 3 0 -10 9 -8 7 -6 5 -4 3 -2 1
Problem 3: print a[i] where i is even
1 3 5 7 9 0 5 9 13 17
Problem 4: print a[i] where i is odd
-2 -4 -6 -8 -10 3 7 11 15 19
Problem 5: print a[i] where a[i] is >= 0
1 3 5 7 9 0 3 5 7 9 11 13 15 17 19
Problem 6: print a[i] where a[i] is odd
1 3 5 7 9 3 5 7 9 11 13 15 17 19
Problem 7: print out the sum of all a[i]'s
94
Problem 8: print out the sum of all a[i]'s where a[i] is odd
124
Problem 9: print a[i] where a[i] is a multiple of 5
5 -10 0 5 15
Problem 10: find the largest a[i] and print it out
19
Problem 11: find the smallest a[i] and print both i and a[i]
9 -10
Problem 12: print out the number of times 5 appears in array
2
Problem 13: print out the number of positive and negative numbers in a
14 positive numbers in a
5 negative numbers in a
Problem 14: print out the number of a[i]'s that are both positive and a multiple
of 5
3
Problem 15: print out those a[i]'s that are multiples of 3 or 5, but not both
3 5 -6 9 -10 3 5 9
Problem 16: copy array a into b but in reverse order, then redo Problem 11 on b
10 -10
Problem 17:
copy each a[i] to array c as follows:
if a[i] is positive, put it in the leftmost available entry in c,
otherwise, put it in the rightmost available entry in c
print c out at the end
1 3 5 7 9 3 5 7 9 11 13 15 17 19 0 -10 -8 -6 -4 -2
*/