How do you input an array without a loop?

How do you input an array without a loop?

“input an array in c without loop” Code Answer

  1. int size=5;
  2. int array[size]; // array of size=5;
  3. for(i=0;i
  4. scanf(“%d”,&array[i]);

How do you assign a number to an array?

Assigning values to an element in an array is similar to assigning values to scalar variables. Simply reference an individual element of an array using the array name and the index inside parentheses, then use the assignment operator (=) followed by a value.

How do you create an integer array which can hold 10 values?

For example, an array named myarray can be initialized with integers 10, 20 and 30 by three methods.

  1. Method 1. int[] myarray = new int[]{10, 20, 30};
  2. Method 2. int[] myarray = {10, 20, 30};
  3. Method 3. int[] myarray = new int[3]; myarray[0] = 10; myarray[1] = 20; myarray[2] = 30;

What is array declaration?

An “array declaration” names the array and specifies the type of its elements. It can also define the number of elements in the array. A variable with array type is considered a pointer to the type of the array elements.

Can you assign an array without a loop?

Of course it’s impossible if you don’t want to write -1 multiple times, but we can assign without loop (In fact, we cannot use a loop to initialize an array even with loop.) Warning: a snippet just for fun, don’t take this seriously.

How to print an array in Java without using loop?

Given an array arr in Java, the task is to print the contents of this array. Loop method: The first thing that comes to mind is to write a for loop from i = 0 to n, and print each element by arr [i]. This article tells how to print this array in Java without the use of any loop.

How to initialize whole array with-1 without loop?

Hey i am trying to initialize all the elements of array with -1. But the catch is without using any loop. But this only assigning first element to -1. So,my question is how can i assign ,help me out.

How to find sum of elements without loops?

Given an array of N elements, the task is to find the Sum of N elements without using loops (for, while & doWhile) and recursion. Recommended: Please try your approach on {IDE} first, before moving on to the solution.