Question

C# - Write C# method  IsSymmetricArray that returns true if the array is symmetric and false otherwise....

C# - Write C# method  IsSymmetricArray that returns true if the array is symmetric and false otherwise. You need to call this method in the Main Method .

Example:

b={ 6,3,2,3,6} is symmetric.
d= {6,3,3,6} is symmetric.

e= { 1,3,3,2} is not symmetric.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

static bool IsSymmetricArray(int[] arr){
int i = 0,j = arr.Length;
while(i<j){
if(arr[i]!=arr[j]){
return false;
}
i++;
j--;
}
return true;
}

Add a comment
Know the answer?
Add Answer to:
C# - Write C# method  IsSymmetricArray that returns true if the array is symmetric and false otherwise....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a method that takes an array of ints and that returns true if there are...

    Write a method that takes an array of ints and that returns true if there are more odd numbers than even numbers. However, as for a casino, 0 is not counted as an odd or an even number. If the array is empty or contains only 0's the method should return false.

  • In java, write method, shuffle, which accepts an array of int, creates a copy of the...

    In java, write method, shuffle, which accepts an array of int, creates a copy of the formal parameter, shuffles the copy, then returns the copied, shuffled array, leaving the formal parameter unchanged. Shuffling is a process of swapping each element of array with another element randomly chosen from the array. For testing the shuffle method have main call shuffle, repeatedly having it shuffle its previously returned array until the returned (shuffled) array is identical (equal) to the original array that...

  • JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a...

    JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...

  • 3. Write a method buildString which takes a 2D array of characters (char), and returns a...

    3. Write a method buildString which takes a 2D array of characters (char), and returns a string that is built from all the characters in that array. For example, the following method call should return "hello!" buildString( new char[] [ 'h', 'e',

  • 10. TRUE or FALSE: Write TRUE if the statement is always true; otherwise, write FALSE. _a....

    10. TRUE or FALSE: Write TRUE if the statement is always true; otherwise, write FALSE. _a. {0} c{{0}, {{0}}} _b. Ø $ ({1, 2}), the power set of {1,2} c. If5<3 then 8 is an odd integer. d. The relation R = {(a,b), (b,a)} is symmetric but not transitive on the set X = {a,b}. e. The relation {(1,2), (2,2)} is a function from A={1,2} to B={1,2,3} _f. If the equivalence relation R = {(1,1), (2,2), (3,3), (4,4), (1,3), (3,1),...

  • Ch. 09: Exclusive find in Array (Arrays, conditional, counter) Write a method that will receive an...

    Ch. 09: Exclusive find in Array (Arrays, conditional, counter) Write a method that will receive an array of integers and an integer value as a parameter. The integer value received as the second parameter will be searched within the Array received as the other parameter. The method will return true if the value appears only once in the Array. Use the "documentation shown in the program as a guide". As an example, if the array received was the sequence of...

  • Given an array of strings, return true if each string's size is equal or greater than...

    Given an array of strings, return true if each string's size is equal or greater than the one before, otherwise return false. The array will be length 2 or more. Example 1: If the names array contains… “Edwin” “Satish” “Solomon” “Massoud” …then the function call stringsIncreasing (names, 4) returns true. Example 2: If the names array contains… “Janet” “Linda” “Jackie” “Marta” …then the function call stringsIncreasing (names, 4) returns false since string Jackie comes before Marta and has more letters...

  • In c++ 1. Write a function named findTarget that takes three parameters - numbers: an array...

    In c++ 1. Write a function named findTarget that takes three parameters - numbers: an array of integers size: an integer representing the size of array target: a number The function returns true if the target is inside the array and false otherwise 2. Write a function min Valve that takes two parameters: myArray an array of doubles - size: an integer representing the size of array The function returns the smallest value in the array 3 Wrile a funcion...

  • 1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if...

    1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...

  • A method stub, or signature, is the first line of a method. Write a class that...

    A method stub, or signature, is the first line of a method. Write a class that contains the following “stubs” for methods used in measurement conversion. You do not have to implement the methods. Correct response: public void showMeters(int numMillimeters){} Write a method that takes two integers and displays their sum. Write a method that takes five doubles and returns their average. Write a method that returns the sum of two randomly generated integers. Write a method that takes three...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT