Answer:
Option (A)
Explanation:
See attachment for options
From the options, the code segment of option (A) answers the question and the explanation is as follows:
I added a second attachment which illustrates the movement
function (solveMaze) {
moveForward(); ---- The robot moves up (to position 1)
moveForward(); ---- The robot moves up (to position 2)
rotateRight(); ---- The robot changes where it faces (however, it is still at position 2)
<em>while(canMove("forward")) { moveForward(); } </em>---- This is repeated until the robot reaches the end of the grid (i.e. position 3 and 4)
rotateLeft(); ---- The robot changes where it faces (however, it is still at position 4)
moveForward(); ---- The robot moves up to the gray square
Answer:
The code to this question as follows:
Code:
if(x < y) //if block that check value of x less then value of y
{
if(x<z) // inner if block that check value of x less then value of z
{
min = x; //assign value of x in min variable
}
else // inner else block when condition is false
{
min = z; //assign value of z in min variable
}
}
else //outer else block
{
if(y<z) //if block to check value of variable y is less then value of z
{
min = y; //assign value of y in min variable
}
else //else block
{
min = z; //assign value of z in min variable
}
}
Explanation:
In the given question it is defined, that an integer variable " x, y,z, and min" is declared, in which variable "x,y, and z" value is defined, and the variable is used to assign a big value.
- To check the biggest value we use the if-else statement in which, and if block check value of x is less than then the value of y if this condition is true so, inside this another if block declares, that will check if the value of x is less then z. if this is true, it will assign the value of x in min variable else it will assign the value of z in min.
- In the outer else part, another conditional block has used, that checks if the value of y is less than then the value of z if it is true, it assigns the value of y in min else it will assign the value of z in min.
Answer:
a)
for(x=0;x<20;x=x+2)
cout<< x << ' ';
cout<< endl ;
<u>Output</u>
0 2 4 6 8 10 12 14 16 18
In this code we are initialing x with 0, check if it is less than 20, then printing the value 0.
Then we increment x value with 2 and check and print again until the x value tends to be equal or more than 20.
<u>C++ program for verifying</u>
#include <iostream>
using namespace std;
int main()
{
int x;
for( x=0;x<20;x=x+2)
cout<< x << ' ';
cout<< endl ;
return 0;
}
<u>Output</u>
0 2 4 6 8 10 12 14 16 18
(You can check on any ide for confirmation)
b)
i=10;
for (;i>0; i =i/2;)
cout<< i;
This code will produce error expected ‘)’ before ‘;’ token
for(;i>0; i =i/2;)
because for loop consist three parameters and in this loop there are 4 parameters.
If we remove semicolon after i/2,
for(;i>0; i =i/2)
then it will produce an output.
10 5 2 1
<u>C++ program for verifying</u>
#include <iostream>
using namespace std;
int main() {
int i=10;
for(;i>0; i =i/2;)
cout<< i;
return 0;
}
<u>Output</u>
Error-expected ‘)’ before ‘;’ token
for(;i>0; i =i/2;)
In the Deck Builder, initialize the 52 cards (along with the 4 jokers, which should be called “wild” and the suit is “wild”).
<h3>Public class Deck</h3>
private final List<Carta> Deck;
public Baralho() {
listaCartas = new ArrayList<>();
String[] naipes = {"club", "spade", "heart", "diamond"};
int pos = 0;
Carta c;
With this code we will be able to create the Deck, initialize the 52 cards together with the 4 jokers.
Learn more about Deck in brainly.com/question/1660537