Using C# how would you write these methods Method Summary int SumArray(int[] arr
ID: 3862236 • Letter: U
Question
Using C# how would you write these methods
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){
return sum;
}
2. void Increment(double[] array){
for(int i=0;i<array.length;i++)
array[i]=array[i]+1;
}
3.bool ContainsNegative(double[] array){
for(int i=0;i<array.length;i++){
if(array[i]<0)
return true;
}
return false;
}
4.void PrintReverse(string[] array){
}
5. int Max(int[] array){
}
Note:Please do ask in case of any doubt,thanks.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.