Draw a memory diagram to keep track of the values that each variable contains
int a = 5;
int b = 10;
a = a + b;
b = a - b;
a = a - b;
17/5
17.0/5
17/5.0
17.0/5.0
17%2 == 1
-17%2 == 1
1729/10
172/10
17/10
1/10
1729%10
172%10
17%10
1%10
5 > 3
5 > 3 == true
5 > 3
, and,5 > 3 == true
int result = 17/5
int result = 17/5.0
float result = 17/5
float result = 17/5.0
Please describe execution in as much detail as you can, avoiding the use of technical terminology (e.g state "a large white circle in the top right of the screen" as opposed to "a white ellipse of radius 500 centred at co-ordinates (300, 50)).
void setup() {
size(200, 200);
}
void draw() {
background(255);
if (mousePressed) {
fill(0);
circle(width/2, height/2, 50);
}
}
draws a circle with radius 50
, with the circle's center at the current position of the mouse. The screen should have the dimensions 200 x 200
.
Assuming a, b
are integer variables that holds random values, draw the flowchart for the following code:
int mystery;
if(a >= b) {
mystery = a;
}
else {
mystery = b;
}
Assuming a, b, c
are integer variables that holds random values, draw the flowchart for the following code:
int mystery = c;
if(a >= b) {
if(a >= c) {
mystery = a;
}
}
else {
if(b >= c) {
mystery = b;
}
}
You can compare your solution with our solution at code2flow.
- "Number is even" if the value in
num
is even - "Number is odd" if the value in
num
is odd.
Write a statement that stores, in variable d
, the last digit of an existing variable n
. Assume n > 0
.
- 1, if
a
is even. - -1, if
a
is odd.
- 1, if both
a
andb
are even. - -1, if both
a
andb
are odd. - 0, if one of
a
andb
is even and the other one odd.
int result = 7;
if (result >= 10)
{
if (result % 2 == 1)
{
result = 0;
}
else
{
result = 1;
}
}
else
{
if (result % 2 == 1)
{
result = 3;
}
else
{
result = 2;
}
}