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# Sharp program to create a new array of integers and length 1 or more. The length of the new array will be double length of the given array and all the elements are 1 except the first element which is equal to the given array
Q:

Write a C# Sharp program to create a new array of integers and length 1 or more. The length of the new array will be double length of the given array and all the elements are 1 except the first element which is equal to the given array

0

Write a C# Sharp program to create a new array of integers and length 1 or more. The length of the new array will be double length of the given array and all the elements are 1 except the first element which is equal to the given array

Sample Output:

New array: 10 0 0 0 0 0 0 0 0 0

All Answers

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

using System;
namespace exercises
{
   class Program
    {       
        static void Main(string[] args)
        {
          int[] item = test(new[] { 10, 20, -30, -40, 30 });            
           Console.Write("New array: ");         
           foreach(var i in item)
            {
               Console.Write(i.ToString()+" ");
            }          
        }        
       public static int[] test(int[] nums)
          {
            int elements = nums.Length * 2;
            int[] doubleNums = new int[elements];

            doubleNums[0] = nums[0];
            return doubleNums;
          } 
   }
} 

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