Assignment 6 program to do the following write a complete Th

Assignment 6 program to do the following write a complete The rain program will call series of functions to process a set data, will two arrays aeat second function will print the values etored in an of the value Another function w ill the average format tored in an array. A fourth function will construct a pew ar ay from two existing arrays. Here are the details on the main program. 1. The main program will read in a parameter value (which the main program will size). Note main program reads a The main program will call a function readdata to read size items into two arrays (which the main program will call first and second) The main program will call a function printarray (twice for the first and once for the second array) which will print the values stored in the arrays Before the main program calls the printing function, each time it should print a beading saying what the heading could say \"the first array\") s being printed main program will call a function average which will find the average of the size values stored in each array (the average of the size values stored in the first array, and the average of the size values stored in the second array) main program will Print these values, together with relevant messages. The main program will call a function addonto which will add the elements from cne array onto the end of the in the new other, forming a new array. The number of elements array is twice the number of elements in either the original array should be printed calling the function prin array), with an appropriate add onto the end of second, and once Eo add second onto the end of first Each new array should be printed using the function (w an beading) The main program will call the function average two more times to find the average of the values stored in the two new arrays made Part 4. The main program will print these values with messages.

Solution

Here goes the required program code for answering the first four questions:

#include <stdio.h>
int main()
{
    int size;
    printf(\"please enter the size of the array\");
    scanf(\"%d\",&size);
    int arraySize=size*2;
    int a[arraySize],b[arraySize];
    readdata(a,b,size);
    printf(\"the first array:\");
    printarray(a,size);
    printf(\"the second array:\");
    printarray(b,size);
    printf(\"average of first array:\");
    average(a,size);
    printf(\"average of second array:\");
    average(b,size);
    printf(\"a onto b array:\");
    addonto(a,b,size);
    printf(\"b onto a array:\");
    addonto(b,a,size);
    return 0;
}
void readdata(int a[],int b[],int size){
    int i=0;
    printf(\"please enter array a\");
    for(i=0;i<size;i++){
        scanf(\"%d\",&a[i]);
    }
    printf(\"please enter array b\");
    for(i=0;i<size;i++){
        scanf(\"%d\",&b[i]);
    }
}

void printarray(int array[],int size){
    int i=0;
    for(i=0;i<size;i++){
        printf(\"%d\\t\",array[i]);
    }
    printf(\"\ \");
}
void average(int array[],int size){
    int i=0;
    int sum=0,average=0;
    for(i=0;i<size;i++){
        sum=sum+array[i];
    }
    average=sum/size;
    printf(\"%d\ \",average);
}
void addonto(int array1[],int array2[],int size){
    int i=0,j=size;
    int arraySize=size*2;
    int array3[arraySize];
    for(i=0;i<size;i++){
        array3[i]=array1[i];
    }
    for(i=0;i<size;i++){
        array3[j]=array2[i];
        j++;
    }
    printarray(array3,arraySize);
}

*The given function names are used in the program

*required parameters are being used since the parameter options are not provided.

 Assignment 6 program to do the following write a complete The rain program will call series of functions to process a set data, will two arrays aeat second fun
 Assignment 6 program to do the following write a complete The rain program will call series of functions to process a set data, will two arrays aeat second fun

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site