Please help me with this in C# language.
Returning an array from a function
The goal for this exercise is to make sure that you return an array from a method (as a return value). Also: to give you more practice creating and using methods/functions.
What you need to do for this exercise:
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ArrayReturnMethods
{
class Program
{
static void Main(string[] args)
{
int[] arr;
arr = CreateRandomlyFilledArray(10);
Console.WriteLine("Array with size 10 is: ");
PrintArray(arr);
}
private static void PrintArray(int[] arr)
{
for (int i = 0; i < arr.Length; i++)
Console.WriteLine(arr[i]);
}
public static int[] CreateRandomlyFilledArray(int size)
{
int[] Array = new int[size];
Random random = new Random();
for (int i = 0; i < size; i++)
{
Array[i] = random.Next(1, 101);
}
return Array;
}
}
}
output
If you have any query regarding the code please ask me in the
comment i am here for help you. Please do not direct thumbs down
just ask if you have any query. And if you like my work then please
appreciates with up vote. Thank You.
Please help me with this in C# language. Returning an array from a function The goal...
1.Write code for a Java method, printArray, that takes an int array as parameter and prints it out, one element per line. public static void printArray (int[] values){ Methods that do NOT return a result have “void” as return type. Notice how an array parameter type is passed, int [] }// end printArray 2.Write code for a Java method that takes in as input parameter an integer number, say num, and returns a double array of size num with all...
please help me with this in C# language. Constructors The goal for this exercise is to understand what constructors are, how to define them, and how to call them, including ‘default’ constructors, and including the use of overloading to provide multiple constructors. One of the advantages of having a clear separation between the public interface of an object and private internal implementation of an object is that once you've got the data in the object you can then ask the...
I need help in this please, in the c# language. Objects As Parameters The goal for this exercise is to define the Television object, which you will be using in several, subsequent exercises. For all the methods that you implement (in this course (not just this exercise, but in this course, as you go forwards)), you should remember that since method is public, anyone, anywhere can call the method. Even people whom you never thought would call this method. Therefore,...
In this lab, you will create one class named ArrayFun.java which will contain a main method and 4 static methods that will be called from the main method. The process for your main method will be as follows: Declare and create a Scanner object to read from the keyboard Declare and create an array that will hold up to 100 integers Declare a variable to keep track of the number of integers currently in the array Call the fillArray method...
What to submit: your answers to exercises 1, 3, and 4 and separate the codes to each question. Using your solution to question 3 of Lab Practice 2, modify it to create a class that contains a static method; the method takes a string as a parameter and returns a boolean value indicating whether the parameter string has repeated characters in it or not. That is, return true if there is at least one character which appears more than once...
Java question Q1) Use the following code snippet which generates a random sized array with random contents to complete the following problems: public int [] createRandomArray() { int size = (int) (Math.random() * 10) + 1; int[] array = new int [size]; for (int i = 0; i < array.length; i++) { array[i] = (int) (Math.random() * 10 ) + 1; } return array; } Assignment...
Write a JAVA program with methods that initializes an array with 20 random integers between 1 and 50 and then prints four lines of output, containing 1)The initialized array. 2)Every element at an even index. 3)Every even element. 4)All elements in reverse order. Requirements (and hints): 1. Build a method that takes any integer array as input and prints the elements of the array. ALL printing in this lab must be done using a call to the printArray method and...
JAVA PROG HW Problem 1 1. In the src −→ edu.neiu.p2 directory, create a package named problem1. 2. Create a Java class named StringParser with the following: ApublicstaticmethodnamedfindIntegerthattakesaStringandtwocharvariables as parameters (in that order) and does not return anything. The method should find and print the integer value that is located in between the two characters. You can assume that the second char parameter will always follow the firstchar parameter. However, you cannot assume that the parameters will be different from...
daily21. Computing 1. C programming Please provide comments and write pre-condition and post-condition for the function. Description Create a project called Daily21. Add a source file called daily21.c into the project. In this exercise, you will practice working with an array of integers. In the main function, you first need to create an integer array with 10 elements in t. Use a loop to read 10 integers from the user and store the values to the array (in the order...
Part 1- Method practice Create a main method. In there, make an array of 100 random integers(numbers between 0 and 1000). Create a method to find average of the array. Pass the array and return the number(double) that is the average In the main method, call the method created in Step 2. Print out the average Create a method to find the min value of the array. Pass the array and return the int that is the smallest.(pass the value...