Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find all the errors in this C program 1/* Computes the sum of the array */ int sum(int n, int * arr) int i, sum;

image text in transcribed

Find all the errors in this C program

1/* Computes the sum of the array */ int sum(int n, int * arr) int i, sum; arr += n; sum += * (arr+i); 9 /* Fills the array with the values 10 * 1*2, 2-2, 3*2,..-, (n-1) 2, n*2 / 11 void fil!Squares(int n, int arr) 12 13 14 15 16 17 18 19 * Reads an integer n from arguments, 20 21 int i; arr [i] i*i; = Eree (arr) return arri * fills array with squares, and computes *the sum of the squares. Prints out the ksum before freeing all used memory. */ 23 int main(int argc, char argv]) 24 25 26 27 28 29 30 31 32 int n, totali int arr; if (ar printf ("usage: /squares n "); return l; n atoi (argv [2] ) ; arr= (int*) malloc (n); 34 35 36 37 38 39 40 fillSquares (arr) total = sum (arr) ; printf ("total: %d ", total); free (argv); 4 3

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions