Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need this in C programming these are all the things i need to do: to the code i already have create functions to do the

Need this in C programming

these are all the things i need to do: to the code i already have

create functions to do the following:

- initialize elements to zero

- print the values in a tabular format

- randomly assign values to the elements of the array

- sum up the values in the array

- find the largest value in the array

- find the index of the smallest value in the array

- find the average of the values in the array

- allow the user to input the values for the array

- shift the values stored in the array to the right one element, place the last value in the first element

for example:

1 2 3 4 5

becomes

2 3 4 5 1

 #include  #include  /* run this program using the console pauser or add your own getch, system("pause") or input loop */ void initToZero(int array[], int arraySize); void printArray(int array[], int arraySize); void randomArray(int array[], int arraySize); int sumArray(int array[], int arraySize); int largeArray(int array[], int arraySize); int main(int argc, char *argv[]) { int intArray[10]; printArray(intArray, 10); initToZero(intArray, 10); printArray(intArray, 10); randomArray(intArray, 10); printArray(intArray, 10); int sum = sumArray(intArray, 10); printArray(intArray, 10); printf(" Value of sum is %d", sum);// sumArray(intArray, 10)); printf(" Largest value is %d", largeArray(intArray, 10)); return 0; } void initToZero(int array[], int arraySize){ int i = 0; for(i = 0; i < arraySize; i++){ array[i] = 0; } } void printArray(int array[], int arraySize){ int i = 0; for(i = 0; i < arraySize; i++){ printf(" Element %d is %d", i, array[i]); } } void randomArray(int array[], int arraySize){ int i = 0; for(i = 0; i < arraySize; i++){ array[i] = (rand() % 10 + 1); } } int sumArray(int array[], int arraySize){ int i = 0; int sum = 0; for(i = 0; i < arraySize; i++){ sum = sum + array[i]; } return sum; } int largeArray(int array[], int arraySize){ int i = 0; int largest = array[0]; for(i = 1; i < arraySize; i++){ if(array[i] > largest){ largest = array[i]; } } return largest; } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

What are the objectives of job evaluation ?

Answered: 1 week ago

Question

Write a note on job design.

Answered: 1 week ago

Question

Compute the derivative of f(x)cos(-4/5x)

Answered: 1 week ago

Question

Discuss the process involved in selection.

Answered: 1 week ago