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 the likely results of running the following code fragment? Why? int *ptr = (int *) 0xfeedbeef ; *ptr = 0 ; Suppose a class uses a dynamically-allocated integer array, pointed to by an int* variable named data. The current capacity of the array is stored in the integer variable capacity. The following code fragment is meant to dyamically resize the array, doubling its capacity. What is the major memory error and how would you detect it? int *tmp...
Question 116 pts (TCO 2) What is the output of the following code? void func(int x) { x = x * 2; } int main( ) { int x = 10; func(x); cout << x << endl; } 20 30 10 5 Question 126 pts (TCO 2) A derived class is typically an example of _____. a “has a” relationship an “is a” relationship a “uses a” relationship an “is used” relationship Question...
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;
11. What is the output of the following program fragment? int v[5] = {10, 20, 30, 40, 50}; for (int i=3; i>0; i--) { cout << v[i] << " "; } A. 102030 B. 302010 C. 403020 D. 40302010 12. Given the following code: char a[20]; char b[30]; Copy(a, b); // Copy all elements of b into a What is the best signature (header) of the Copy function? A. void Copy(char x[], char y[]) B. void Copy(const char x[], char...
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...