Answer:
1.) 25 ; 15 ; 15
2.) 50 ; 15 ; 50
Explanation:
In the first function written :
The variable val was initially decaled or assigned a value of 25 and that was what was printed first.
However, after the example function was written, the val variable was finally assiagned a value of 15 within the function. However, it was also declared that the global variable takes uonthe val value. Hence, the val variable initially assigned a value, of 25 changes to 15 globally.
For the second code :
From the top:
Val was assigned a value of 50 ;
Hence,
print(val) gives an output of 50
Within the function definition which prints the value of val that is assigned a value of 25 within the function.
Since tbe global variable isnt reset.
Printing Val again outputs 50;since ito is outside the function.
Answer:
#include<iostream>
using namespace std;
int main() {
cout<<"Enter The Size Of Array: ";
int size;
bool isBestCase=false;
cin>>size;
if(size<=0){
cout<<"Error: You entered an incorrect value of the array size!"<<endl;
return(0);
}
int array[size], key;
cout<<"Enter the numbers in the array, separated by a space, and press enter:";
// Taking Input In Array
for(int j=0;j<size;j++){
cin>>array[j];
}
//Your Entered Array Is
for(int a=0;a<size;a++){
cout<<"array[ "<<a<<" ] = ";
cout<<array[a]<<endl;
}
cout<<"Enter a number to search for in the array:";
cin>>key;
for(i=0;i<size;i++){
if(key==array[i]){
if(i==0){
isBestCase=true; // best case scenario when key found in 1st iteration
break;
}
}
}
if(i != size){
cout<<"Found value "<<key<<" at index "<<i<<", which took " <<++i<<" checks."<<endl;
} else{
cout<<"The value "<<key<<" was not found in array!"<<endl;
cout<<"We ran into the worst-case scenario!"; // worst-case scenario when key not found
}
if(isBestCase){
cout<<"We ran into the best case scenario!";
}
return 0;
}
Explanation:
The C++ source dynamically generates an array by prompting the user for the size of the array and fills the array with inputs from the user. A search term is used to determine the best and worst-case scenario of the created array and the index and search time is displayed.
<span>Fire extinguishers should be stored in a
boat at the engine area and near the operator. A fire extinguisher should be
put near the engine because the engine of the boat is a fire hazardous place
and this is the area where a fire could start.
The fire extinguisher should be installed properly using a mounting
bracket to hold the extinguisher in place. There are different types of
extinguishers that should be installed in the boat, these are type A, B, and C
extinguishers. Type A extinguishers can turn off the fire caused by combustible
solids like wood and paper. Type B extinguishers can turn off fire caused by
gasolines, oil, and greases. While Type C extinguishers can turn off fire
caused by an electrical problem.</span>
Answer:
This question required option (See Explanation)
Explanation:
Required
How to declare 2D array
Using Java as a programming language of reference, the syntax to declare a 2D array is:
Data-Type [][] Array-Name = new Data-Type[Rows][Column]
From the question, the data type is String. So, the syntax becomes
String [][] Array-Name = new String[Rows][Column]
Assume the array name is: myArray; The above becomes
String [][] myArray= new String[Rows][Column]
<em>I will not assume values for Rows and Column, but it is worth saying that Rows and Columns are positive integers greater than 1 to make the array a 2 D array</em>