QUESTION 30 Which of the following statements are valid? OA, int [] [] r = new int [2]; B. int [] x = new int []; C. int [] [] y = new int [3] []; D. int [] [] z = {{1, 2}}; E, int [] [] m = {{1, 2}, {2, 3}}; F, int [] [] n = {{1, 2}, {2, 3}, }; %3D
Q: Repeat Part one, but this time use arrays of char (instead of int), and stop receiving input into…
A: Actually, array is a collection of elements.
Q: Q4. (A) Write a program that reads from the user a string matrix with NxN dimension. The matrix is…
A: //C++ program #include<iostream> using namespace std; int main(){ int N;…
Q: Write a program to store the above 3 class scores in Jagged Array by initialing all these values ,…
A: A Jagged Array is an array which is a two dimensional array where the columns changes from one row…
Q: Which of the statements below is an incorrect array declaration? * O int [] arr = new int[5]; O…
A: An array stores multiple values in a single variable. 1-D array consists of only one index while 2-D…
Q: Question 1 a. What digits are used in the binary number system? b.What digits are used in the…
A: Answer 1) a) Binary number system in mathematics, positional numeral system employing 2 as the…
Q: What will be the array S, after execution of the following statement? SDB 3.2 DUP (0,2).9.2…
A:
Q: in C++ : You are given an array of integers representing asteroids in a row. For each asteroid…
A: Coded in C++, I used stacks in solving this problem.
Q: int mystery(const int a[), size t n) int x = a[0]; for (size_t i = 1; i < n; i++) if (a[i] < a[x]) x…
A: EXPLANATION Firstly x = 4, then we compare a[1] < a[4] that means 2 < 5 which is true and new…
Q: What is the content of this element arr[ 3 ] in the following array after executing the following…
A: Given: int arr[5] = {3,2,0}; arr[3] = arr[arr[1]]*2; To find: Value of arr[3]
Q: According to the following program segment answer the following questions. ArrayList animals = new…
A: Let's understand step by step : Answer (i) : 1. ArrayList <String> animals=new…
Q: Analyze the below code and answer the questions:
A: In this question, a piece of code is given and asked some sub parts. Given code: #include…
Q: • Rewrite line 7 of the following program using a printf syntax . Write the method swap in the…
A: The swap method is used to exchange the position of two elements.
Q: In this program you will take two tables using python cars = ["Buick","Ford","Honda"] colors =…
A: Actually, python is a easiest programming language.' It has a concise(less) code. It is a…
Q: Given the program below, answer the succeeding questions: #include #include using namespace std;…
A: The typedef keyword enables a developer to give new names to types like int or, templated types; it…
Q: Rewrite line 7 of the following program using a printf syntax • Write the method swap in the program…
A: Java program: public class Swap{ public static void main(String[] args) { //program…
Q: According to the following program segment answer the following questions. ArrayList animals = new…
A: if (animals.get (j) .compareTo (animals.get (j+1)) This line basically compares the element at jth…
Q: PLEASE ANSWER THE QUESTION IN C! 1) Instead of reading several lines of text, just hard-code the…
A: //a) #include <stdio.h>#include <ctype.h>#include<conio.h>#include…
Q: Find errors and suggest correction, if any, in the following C++ statements. long float x; char *cp…
A: No. Error Corrections i. Too many types float x; or double x; ii. type must be matched char *cp…
Q: 11. What are the values of i and j obtained after the following code fraglHlen is run? int i = 15;…
A: Option 4: i=255 , j=0
Q: The following statement creates an integer array. int[ ] arrayOFNumbers = { 1.3, 4.2, 5.7, 8.2, 3.5…
A: False
Q: 3. Write the appropriate correct array declaration statement in java for each of the given case…
A: Answer:- int[] intArray = new int[5]; intArray = {2, 3, 1, 6, 0}; //array initialization…
Q: bla 5 Q: Choose the missing statements to .generate A array of 4x4 elements 10 3 10 10 6. 4 10 15 9.…
A: Given:
Q: C++ Program
A: Program to generate 15 random numbers from the range of 1 to 50.Store the 15 random numbers in…
Q: 4. Assuming you have initialized the heightWeight array from the previous question like this: double…
A: Correct answer is C (Below i explain you why other is wrong).…
Q: QUESTION 9 Consider the following code segment: int a(10]: We want to use the special for (range…
A: Solution: Given,
Q: English (en) what is the output of the following program? #include void Array( int b[], int size) {…
A: Algorithm: for (initialExpression; testExpression; updateExpression){ // body of the…
Q: float someDataValues [] = new float[30]; for (int i = 1; i < someDataValues.length - 5; i+=4) {…
A: The output is964169324529
Q: 1 #include int main() { int i, j, n, row, col; 2 3 4 5 6 printf("Enter row: "); scanf("%d", &row);…
A: Language is one of the most widely used programming language which has been used to create different…
Q: #include int main(void) { int array1[9]; printf("Enter Array1 elements:"); for(int…
A: Add code line to print your name (Ghadeer) and take a screenshot for the program output: Program…
Q: Suppose me is an int array and pointing to an int array object. Here is a C# for statement to add…
A: To add all numbers in an array, we need to iterate through all the elements of the array, and add…
Q: The following block of code is intending to display the values that store in array. public static…
A: Hi, since there are multiple questions in this post, as per our policy, I'll answer the first…
Q: Incorrect Question 8 Consider the following table for this question. 2 4 8. 10 12 14 16 18 20 22 24…
A: - We need one line statement for getting the value in the green box.
Q: According to the following program segment answer the following questions. ArrayList animals = new…
A: the above program is to add a unique element in the array.
Q: 1. Given the declaration Circle[] x = new Circle[10], which of the following statement is most…
A: Note: We are authorized to answer one question at a time, since you have not mentioned which…
Q: Output in C++
A: C++ PROGRAM:#include <iostream>void mystery(int x[], int n) {int temp; for(int i=0; i<n / 2…
Q: Assume that the following program segment is executed. What is the first element of testArray3 after…
A: Ans 1: The following program executed and the first element of the testArray3 is: brown public…
Q: Given the following variable declaration: int* newDimensions; Which assignment statement will…
A: Given variable - int* newDimensions;
Q: 18.16 Define a method named getWordFrequency that takes an array of strings, the size of the array,…
A: Coded using Java.
Q: 7. What is the output of the following code? int *p; int *q; p = new int [5]; p[0] = 5; for (int i =…
A: Kindly Note: As per our guidelines we are supposed to answer only one question. Kindly repost other…
Q: Q1: Write a brief description to each line in the following programs, and determine the output of…
A: // determine the output of the program for multiplication of two matrix?. #include<stdio.h>…
Q: Complete the following program to print the values of each inner array in a single line? (Note:…
A: As per the Bartleby guideline, the first question is solved. You can post the remaining question as…
Q: Determine whether the following array declarations are valid. If a declaration is valid, determine…
A: The following are the valid array declarations: 1. int list[] = {18, 13, 14, 16}; // Size of the…
Q: QUESTION 8 Consider the following code segment: int a[45): P(a); / call function p with argument a…
A: The problem is based on the basics of pointers and arrays in programming languages.
Q: Assume we have two arrays (al and a2) that already declared and initialized. int al[] = {1, 2, 3, 4,…
A: Required:
Q: And the main() has declared an array of integers as below and has filled each integer with a random…
A: In this question, we asked to write C++ function only to calculate the smallest numbers from each…
Q: Write a simple polling program that allows users to rate five topics from 1 (least important) to 10…
A: Pogram code #1:
Q: #include int main(void) { int a[3][3] = {1,3,5,7,9}; int i,j,sum=0; for(i = 0; i < 3; i++) for (j =…
A: #include<stdio.h> int main() { int a[3][3] = {1,3,5,7,9}; int i,j,sum=0; for(i =…
Q: Write statements to assign array variable "a" to refer a two dimensional array c by n: the first row…
A: pattern printing and initializing the 2-d array with zero's
Q: Read and understand the statements. Choose the correct answer from the choices given. 1. If you…
A: Note: we are only allowed to solve one question in one post. to get answers to others, please post…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
- Question 1 Work your way through the following code fragments. What would be printed? a) int i = -23; int * p = &i; printf("*p = %i\n", *p); b) int i; int * p = &i; printf("*p = %i\n", *p); c) int i = 48; int * p; printf("*p = %i\n", *p); d) int i = 10;int * p = &i;int j; j = ++*p; printf("j = %i\n", j);printf("i = %i\n", i); e) int i = 10, j = 20;int * p = &i;int * q = &j; *p = *q;printf("i = %i, j = %i\n", i, j);printf("*p = %i, *q = %i\n", *p, *q); i = 10; j = 20; p = q;printf("i = %i, j = %i\n", i, j);printf("*p = %i, *q = %i\n", *p, *q);x = zeros(5,5)for i = 1:1:5for j = 1:1:5x(i,j) = i*j;endendWhich of the following best describes the variable i? 1. An array of length 5 2. A constant value in the equation i*j 3. A counting variable that indexes columns 4. A counting variable that indexes rowsQuestion 1. (-) Analyze the below code: #include <stdio.h> int main(void) { int array1[9]; printf("Enter Array1 elements:"); for(int i=0;i<9;i++) scanf("%d",&array1[i]); for(int i=0;i<9;i++) printf("%d ",array1[i]); return 0; } Add code line to print your name (Ghadeer) and take a screenshot for the program output Array elements should be given as: (-) 3 5 7 11 13 17 19 23 31 Explain the code in your own words in details -) Update the code to have float array elements of size 8. (-) Take a screenshot for the program output. Array elements should be given as : (-) 2.3 4…
- Implement the function below. void swap(int pos1, int pos2){} Initial code to be completed: class ArrayList : public List { int* array; int index; int capacity; void dyn_all_add(){ int cap = ceil(capacity * 1.5); array = (int*)realloc(array,cap * sizeof(int)); capacity = cap; } void dyn_all_rem(){ int cap = capacity - (capacity/3); array = (int*)realloc(array,cap * sizeof(int)); capacity = cap; } public: // CONSTRUCTOR ArrayList() { capacity = 4; array = (int*)malloc(capacity); index = 0; } int add(int num) { if (index == capacity){ dyn_all_add(); } *(array + index) = num; index++; return index; } int get(int pos){ if (pos-1 < index){ return *(array + pos-1); } return -1; } int size(){ return index; }…For this assignment please use 2 arrays. Write a program DiscreteDistribution.java that will take an integer command-line argument m, followed by a sequence of positive integer command-line arguments a1,a2,…,ana1,a2,…,an, and will print m random indices (separated by whitespace), choosing each index i with probability proportional to ai.What is the value of the following expressions (or ERROR)?1. __________ s.length()2. __________ t.length()3. __________ 1 + a4. __________ a.toUpperCase()5. __________ "Tomorrow".indexOf("r")6. __________ "Tomorrow".lastIndexOf('o')7. __________ "Tomorrow".substring(2,4)8. __________ (a.length() + a).startsWith("a")9. __________ s = = a10. __________ a.substring(1,3).equals("bc")
- Write in JAVA, JUST CHANGE THE SWAP PART I don't want int i and j in (public static void swap(int[] array, int i, int j)) this part. I want you to do it by writing( public static void swap(int[] array){ Just initialize i and j somewhere else please. How can you do that? public class SelectionSort {public static void main(String[] args) {int[] intarray = {20, 35, -15, 7, 55, 1, -22};for(int lastUnsorted = intarray.length-1;lastUnsorted > 0;lastUnsorted--){// if largest is in 0th index// we start from the 1st index// if 1st is greater than it, swap the elementint largest=0;for(int i=1; i<=lastUnsorted; i++){if(intarray[i] > intarray[largest]){largest = i;}}swap(intarray, largest, lastUnsorted);}for(int i=0; i<intarray.length; i++){System.out.println(intarray[i]);}}public static void swap(int[] array, int i, int j){if(i == j){return;}int temp = array[i];array[i] = array[j];array[j] = temp;}}Answer the given question with a proper explanation and step-by-step solution. In Java, please. Consider the following problem. Input: an array of integers A[] Output: rearranges the array to have the following property: Suppose the first element in the original array A[], A[0] = x. In the rearranged array, suppose that x is at index i, that is A[i] = x. Then, we want the rearranged array to be such that A[j] <= x for all j < i and A[j] > x for all j > i. The rearranging should place all the values less than (or equal to) x to the "left" of x and all values larger than x to the right of x. Here's an example. Suppose the array has the elements in this initial order: 4 3 9 2 7 6 5 A[0] = 4. After rearranging elements, we get: 3 2 4 5 9 7 6 That is, A[0] = 4, is positioned in the resulting array so that all elements less than 4 (that is, 2, 3) are to its left (in no particular order), and all elements larger than 4 are to its right (again, in no particular order).void radixSort(int arr[], int n) { intm=getMax(arr, n); for (intexp=1; m/exp>0; exp*=10) countSort(arr, n, exp); } void printData(int arr[], int start, int len) { if( start>=len ) return( 0 ); printf("%d\n", arr[start]); printData(arr, start+1, len); } int main() { intarr[]= {8, 9, 3, 4, 7, 2, 5, 6, 1}; intn=sizeof(arr) /sizeof(arr[0]); radixSort(arr, n); printData(arr, 0, n); return0; } In MIPS
- Explain this C code line per line please #include <stdio.h> #include <malloc.h> void printArray(int**, int); int main() { int i = 0, j = 0, n = 5; int **arr = (int**)malloc(n * sizeof(int*)); for(int i=0;i<n;i++){ *(arr+i) = (int*)malloc(n*sizeof(int)); } for(i=0;i<n;i++){ for(int j=0;j<n;j++){ *(*(arr+i) + j) = 0; } } printArray(arr, n); for(i=0;i<n;i++){ *( *(arr + i) + i) = i+1; } printArray(arr,n); return 0; } void printArray(int ** array, int size) { int i,j; for(i = 0;i<size;i++){ for(j=0;j<size;j++){ printf("%d ", *( *(array + i) + j)); } printf("\n"); } printf("\n"); }*IN JAVA PLEASE* 2)For this exercise, you are given an array of integers. Return true if every element in the array is an odd number, otherwise return false. 3) Given an array of strings, return the array in reverse order. For example, given: reverse({"one", "two", "three"}); You would return: {"three", "two", "one"} 4) For this exercise, you need to shift all the elements in the array one space to the right (increase the index of the element by 1). The last element will wrap around and become the new first element. For example, given: moveUp({"first", "second", "third", "fourth"}); You would return: {"fourth", "first", "second", "third"}Write in JAVA, JUST CHANGE THE SWAP PART I don't want int i and j in (public static void swap(int[] array, int i, int j)) this part. DELETE I, AND J HERE. IT MUST BE JUST INT[] ARRAY I want you to do it by writing( public static void swap(int[] array){ Just initialize i and j somewhere else please. How can you do that? public class SelectionSort {public static void main(String[] args) {int[] intarray = {20, 35, -15, 7, 55, 1, -22};for(int lastUnsorted = intarray.length-1;lastUnsorted > 0;lastUnsorted--){// if largest is in 0th index// we start from the 1st index// if 1st is greater than it, swap the elementint largest=0;for(int i=1; i<=lastUnsorted; i++){if(intarray[i] > intarray[largest]){largest = i;}}swap(intarray, largest, lastUnsorted);}for(int i=0; i<intarray.length; i++){System.out.println(intarray[i]);}}public static void swap(int[] array, int i, int j){if(i == j){return;}int temp = array[i];array[i] = array[j];array[j] = temp;}}