A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C# program to check if a number appears as either the first or last element of an array of integers and the length is 1 or more
Q:

Write a C# program to check if a number appears as either the first or last element of an array of integers and the length is 1 or more

0

Write a C# program to check if a number appears as either the first or last element of an array of integers and the length is 1 or more

Sample Output:

Input an integer:                                                      
25                                                                     
False

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Exercise46
{  
    public static void Main() 
  {
            Console.WriteLine("\nInput an integer:");  
            int x = Convert.ToInt32(Console.ReadLine());
            int[] nums = {1, 2, 2, 3, 3, 4, 5, 6, 5, 7, 7, 7, 8, 8, 9};
            Console.WriteLine( (nums[0] == x) || (nums[nums.Length - 1] == x));
    } 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now