Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C# Method Summary int SumArray(int[] array) Returns the sum of all the elemen

ID: 3862131 • Letter: I

Question

In C#

Method Summary

int

SumArray(int[] array)


Returns the sum of all the elements in “array.”

Example input:

3

5

1

2

4

6

Example output:

        21

void

Increment(double[] array)


Increments each elements in “array” by 1.

Example input:

3.0

5.0

1.0

2.0

4.0

6.0

Example output:

4.0

6.0

2.0

3.0

5.0

7.0

bool

ContainsNegative(double[] array)

Returns true if “array” contains a negative number, otherwise returns false.

Example input:

3.1

5.3

1.2

-2.5

4.0

6.9

Example output:

      true

void

PrintReverse(string[] array)

Print the elements in “array” from right to left.

Example input:

“The”

“soggy”

“cat”

“was”

“unhappy!”

Example output:

       unhappy! was cat soggy The

int

Max(int[] array)

Prints the maximum value found in “array.”

Example input:

12

3

14

5

11

Example output:

       14

Method Summary

int

SumArray(int[] array)


Returns the sum of all the elements in “array.”

Example input:

3

5

1

2

4

6

Example output:

        21

void

Increment(double[] array)


Increments each elements in “array” by 1.

Example input:

3.0

5.0

1.0

2.0

4.0

6.0

Example output:

4.0

6.0

2.0

3.0

5.0

7.0

bool

ContainsNegative(double[] array)

Returns true if “array” contains a negative number, otherwise returns false.

Example input:

3.1

5.3

1.2

-2.5

4.0

6.9

Example output:

      true

void

PrintReverse(string[] array)

Print the elements in “array” from right to left.

Example input:

“The”

“soggy”

“cat”

“was”

“unhappy!”

Example output:

       unhappy! was cat soggy The

int

Max(int[] array)

Prints the maximum value found in “array.”

Example input:

12

3

14

5

11

Example output:

       14

Explanation / Answer

int sumArray(int array[])
{
   int sum=0;
   int n=sizeof(array)/sizeof(int));
   for(int i=0;i<n;i++)
   {
       sum=sum+array[i];
   }
}


void increment(double array[])
{
       int n=sizeof(array)/sizeof(double));
       for(int i=0;i<n;i++)
       {
           a[i]=a[i]+1;
       }
}

bool containsNegative(double array[])
{
       int n=sizeof(array)/sizeof(double));
       for(int i=0;i<n;i++)
       {
           if(array[i]<0)
           {
               return true;
           }
       }
       return false;
}


void printReverse(string[] array)
{
       int n=sizeof(array)/sizeof(string));
       for(int i=n-1;i>=0;i--)
       {
           printf("%s",array[i]);
       }
}

int Max(int array[])
{
       int n=sizeof(array)/sizeof(int));
   int max=array[0];
   for(int i=1;i<n;i++)
   {
       if(a[i]>max)
       {
           max=a[i];
       }
   }
  
  
   return max;
}