# Recent questions tagged arrays

1 vote
Problem : I am new to C programming. I have recently started working on exercise. Please find below my code for your reference: int mydistinct(int a[], int n) { int i, k, j, count=0; int max = a; for (i = 1; i < n; i++) { if (max < a[i]) { ... . In this case my code will only try to count 8,7,6,5 and it will return only four unique numbers. So I am looking for proper guidance in C programming.
1 vote
Problem : I am a student and I am trying to learn python. I like programming so trying my hand on Python but the code which I have written in Python is giving me very strange looking error shown as below for your reference. Error: unsupported operand type(s) for ... array1=[1,2,3,4,5]; encryptedArray=runEncrypt(array1,4); print(encryptedArray); Please guide me in fixing my above error in Python.
Problem: I wrote the following code in python using numpy. But it gives me some error message. The code I wrote is: import numpy as np arrayone = np.array(['Human', 'Birds', 'Groots', 'Oats']) arraytwo = np.array(['Beach', 'Toast']) arraythree ... concatenate TypeError: only integer scalar arrays can be converted to a scalar index Can anyone sort out this error and solve this. Thanks in advance.
1 vote
Problem : I am very new to programming. I have recently started learning C programming. Please find below the one way of initializing the array: I have one doubt about my above program : Which of the following is not a correct way to initialize an array? int n[ 5 ] = { 0, 7, 0, 3, 8, 2 }; int m = ...  15};     printf("m = %d  m = %d   m = %d\n", m, m, m);     return 0; }
1 vote
Problem : I am very new to programming. I need to write a program called swapAdj that must accept the array of integers and after that swap those elements at the adjacent indexes. For example consider the elements 0 and 1 are swapped by the program and after ... note if your array has the odd length then the program must keep final element unmodified. Please help me in writing above program.
1 vote
Problem: Hello good souls, var myarr1 = [1, 2, 3, 4, 5]; var myarr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; I have two simple arrays like above. I want to sort out the common values between those two arrays. So can you find common elements in two arrays javascript for me? Please keep the program as simple as possible that I can understand easily. Thanks for your effort and valuable time buddy.
1 vote
Problem : I am beginner to numpy. I am trying to execute my code but I am facing below error. &ldquo;Valueerror: all the input arrays must have same number of dimensions&rdquo;. I want to have my all the arrays with a same shape. I am trying to fix above error from past couple of days but still unable to fix it. I am looking for some help in fixing above error.
1 vote
Problem: I am doing a online course on python. I got an assginement from there. So I was trying to write a programm using numpy and matplotlib. I am new to python programming. The code I wrote is: import numpy import matplotlib.pyplot def ThisFunction(a): return ... .int(a) TypeError: only size-1 arrays can be converted to Python scalars Do anyone know why this error is happening, please help.
1 vote
Problem: I was doing my coding practice of python using numpy. I wrote this code: def create_traini_data(): trainingday_data =  for img in tqdm(os.listdir(TRAIN_DIR)): label = label_img(img) path = os.path.join(TRAIN_DIR, img) training_data.append([ ... = create_traini_data() traini = traini_data[:-400] It throws error: ValueError: setting an array element with a sequence Can anybody help?
1 vote
Problem : I have very recently started to learn programming in Java. I am trying to execute my java code but I am facing the below error. &ldquo;Exception in thread "main" java.lang.arrayindexoutofboundsexception:&rdquo; I am unable to understand above error. Please find below my code: ... according to my debugger*/ myodd[j] = input[i]; j++; } return myodd; } Please help me in fixing above error.
I wrote some code in java: public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter size of array:"); int size = sc.nextInt(); int[] intArray = new int[size]; for ( ... .journaldev.exceptions.ArrayIndexOutOfBoundsExceptionExample.main(ArrayIndexOutOfBoundsExceptionExample.java:23) What is the problem in my code and why am I getting this kind of error?
Problem: Can any one help me in array programming? What happen when an individual element of an array is passed to a method?
Problem: I am new and learning, I need help, can anyone help by filling in the blanks? The _________ is adequate for searching through small arrays? A) binary B) unary C) linear search D) relative E) None of these
Problem: I am new and learning, I need help, can anyone help by filling in the blanks? A(n) ________ search uses a loop to sequentially step through an array? A) binary B) unary C) linear D) relative E) None of these
Problem: I am new, I need help, can anyone help me by filling in the blanks?? ​The acronym ____________ refers to software that manages data stored in a database.​​ A) ​ERP B) SQL​ C) ​OLAP D) ​DBMS