Question: Q2. write sequential C code to add 2 vectors A and B with A i] i * 3 and B[i]=-*3 as Cli] Ali] + B[i].

 Q2. write sequential C code to add 2 vectors A and

Q2. write sequential C code to add 2 vectors A and B with A i] i * 3 and B[i]=-*3 as Cli] Ali] + B[i]. Also find the sum of all elements in C. Eventually, your code should print the sum (which is 0) as well as the execution time Run your code four times with vector sizes of 1, 10, 50, and 100 million integers. Report the results from these four runs as a comment in your code. (12 marks) Sample run 1: (successful) Sum: 0 Execution time: 0.88 sec Sample run 2: (unsuccessful memory allocation) Not enough memory Notes: Lookup the function clock) from time.h Create your arrays using the syntax: int* the number of integers in the array R. Write code to print the error message if the operating system fails to allocate memory to your arrays, in which case malloc will return NULL R (int*) malloc (n sizeof(int)), where n is * = Marking Guide: +2 for creating arrays, +2 for error checking, +2 for rest of code, +2 for time computation, +4 for reporting correct results as a comment

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!