Hi, please find the answer below:
31. Answer: 1.1
As myArr[0] is assigned 1.1. It will contain 1.1
32. Answer: 1.1
String form of 1.1 is '1.1'
33. Answer 2.2
String form of 2.2 is '2.2'
34. Answer: Array
An array is a group of variables that have the same name and data type and are related in some way.
35. Answer: Four
The array is initialized with four zeros: number = [0,0,0,0]
36. Answer: Declaring the array
When you declare the array, it will initialize all values to 0's.
37. Answer: int[] numbersArray = new int[SIZE];
Valid declaration is of form : datatype [] name = new datatype[size]
38. Answer: 3.3
As myArr[2]=myArray[0]+myArr[1].
39. Answer: 1.1
Because myArr[0]=1.1 is declared.
40. Answer: 3.3
String form of 3.3 is '3.3'
I hope, the explanation is clear and is useful in your understanding.
Question 31 -Given the following code fragment, what value is contained in myArr[O]? const int ARRAYSIZE...
Consider the following C++code snippet and what is the output of this program? # include<iostream> using namespace std; void arraySome (int[), int, int); int main () const int arraysize = 10; int a[arraysize]-1,2,3,4,5, 6,7,8,9,10 cout << "The values in the array are:" << endl; arraySome (a, 0, arraySize) cout<< endl; system ("pause") return 0; void arraySome (int b[], int current, int size) if (current< size) arraySome (b, current+1, size); cout << b[current] <<""; a) Print the array values b) Double...
What is wrong with the following function definition? void fill(const int a[], int size) { for (int i = 0; i < size; i++) { a[i] = 0; } return; } Answers: The function cannot change the array parameter. The array should be passed as a call-by-reference, not call-by-value. The for loop causes an out-of-bounds indexing error. Nothing, the code works fine as is.
8. Given the following code fragment and function definition, what is(are) the output(s)? int funct (int n) int var = 1; while(n > 0) cout << funct(7)<<" "<<funct(0); var *= n; n--; return var;
Write the following function: const int MIN_SIZE = 2; const int MAX_SIZE = 8; const int UNKNOWN = 0; const int RED = 1; const int BLUE = 2; const char UNKNOWN_LETTER = '-'; const char RED_LETTER = 'X'; const char BLUE_LETTER = 'O'; const string UNKNOWN_STRING = "unknown"; const string RED_STRING = "X"; const string BLUE_STRING = "O"; /** * Requires: size <= MAX_SIZE and size is a positive even integer, * 0 <= row && row < size....
QUESTION: ADT stack: resizable array-based implementation for Ch4 programming problem 4 "maintain the stacks's top entry at the end of the array" at array index N-1 where the array is currently allocated to hold up to N entries. MAKE SURE YOU IMPLEMENT the functions: bool isEmpty() const; bool push(const ItemType& newEntry); bool pop(); in ArrayStackP4.cpp //FILE StackInterface.h #ifndef STACK_INTERFACE_ #define STACK_INTERFACE_ template<class ItemType> class StackInterface { public: /** Sees whether this stack is empty. @return True if the...
What does the following code fragment print? Explain the result? int [] a = new int[10]; for (int i = 0; i < 10; i++) a[i] = 9 - i; for (int i = 0; i < 10; i++) a[i] = a[a[i]]; for (int i = 0; i < 10; i++) System.out.println(a[i]);
Question 1) Suppose a program has the following code: const int X = 2, Y = 3; int sum; int values[X][Y] = {{1, 2, 3}, {4, 5, 6}}; for(int i=0; i<X; i++) { sum=0; for(int j=0; j<Y; j++) sum+=values[i][j]; cout<<sum<<endl; } What is this program getting the sum of? Group of answer choices D-) The columns of the 2D array C-) The rows of the 2D array A-) All of the elements of the 2D...
Given the following code segment, int x = 20; int y = 7; what is the data type of the value of the expression (x % y) ? (3 points) Question 1 options: 1) int 2) double 3) numeric 4) Error: possible loss of precision 5) Unable to be determined Question 2 (3 points) Given the following code segment, double x = 42.3; double y = 11.7; what is the data type of the value of the expression (x %...
Q-1: Given the following code fragment, what is its Big-O running time? test = 0 for i in range(n): for j in range(n): test= test + i *j Q-2: Given3 the following code fragment what is its Big-O running time? for i in range(n): test=test+1 for j in range(n): test= test - 2 Q-3: Given the following code fragment what is its Big-O running time? i = n while i > 0: k=2+2 i...
Question 24 Given the following code fragment and the input value of 2.0 for total, what output is generated? double tax; double total: cout << "enter the costof the item\n"; cin >>total: if total >-3.0) tax 0.2: K< endi: cout << total +(total tax) eise tax 0.1 tax) aout ce total +Ktotal