Question: How do I write these code blocks as separate functions? (C programming) Right now, the code blocks below are in my main function. However, they
How do I write these code blocks as separate functions? (C programming)
Right now, the code blocks below are in my main function. However, they need to be their own outside functions and I'm still having trouble writing them. What would these be as their own functions and how would I call them in the main?
What I have declared at the top of my main: int a[10], i, max, *max; 1. User enters a series of integers with 0 as the sentinel to break the loop
for (i=0; i<10; i++) { printf ("Please enter integers (no more than 10 numbers) with a 0 as the last number "); scanf ("%d", a+i); if ((a+i)==0) { break; } }
2. Prints the elements in the array of the user input numbers
printf ("You entered: "); for (i=0; i<10; i++) { printf (" %d", *(a+i)); }
3. Finds the largest number in the array
max=a; *max=*a;
for (i=1; i<10; i++) { if (*(a+i)>*max) { *max=*(a+i); } }
printf ("The largest number in the series is: " %d, max);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
