Assume that a two dimensional integer array myTable[NUM_ROWS] [NUM_COLS]has already declared and initialized. Which XXX/YYY will find the minimum value of all the elements in the array?
int minVal;
XXX:
for(i = 0;i < NUM_ROWS;++i){
for(j = 0; j < NUM_COLS;++j){
if(YYY){
minVal = myTable[i][j];
-----------------------------------------------
Consider the following array definition:
int coins[] = {1,5,10,25,50,100);
what will the following statement display? Not sure if thats a star or a quote * or "
cout<< *(coins + 3);
}
}
}
A.) minVal = 0/ myTable[i][j] > minVal
B.)minVal = myTable[0][0] / myTable[i][j] > minVal
C.)minVal = 0/ myTable[i][j] < minVal
D.)minVal = myTable[0][0] / myTable[i][j] < minVal
In order to find the minimum value in the two dimensional array, first we will assign a variable(here, minVal) equal to the value of first element of the array and then we will iterate through each element of array and check if that element is less than the variable minVal then we will assign the value to minVal as that current element.
So, here correct option is option(D) i.e. minVal = myTable[0][0] / myTable[i][j] < minVal
cout<<*(coins + 3) will print the fourth element of the array because when we write only coins, it is the pointer pointing to the first element of the array and when we add 3 to the coins then it started pointing to the fourth element of the array and *(coins + 3) represents the value present at the address to which coins + 3 is pointing to i.e. the fourth element of the array coins. Fourth element of array is 25 so it will print 25.
PLEASE UPVOTE IF YOU LIKED THE ANSWER
Get Answers For Free
Most questions answered within 1 hours.