imtrying77 imtrying77
  • 07-07-2020
  • Computers and Technology
contestada

What is the value of the var variable after the execution of the following snippet of code:
int var;
var = -1;
var = var - 1;
var = var - var;

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 12-07-2020

Answer:

The value of var is 0

Explanation:

Given:

The code snippet above

Required

Find the value of var after program execution

This line declares var as type integer

int var;

This line initializes var to -1

var = -1;

This line subtracts 1 from var; var - 1 = -1 -1 = -2

var = var - 1;

At this stage the value of var is -2

This line subtracts the value of var from var; i.e. -2 - (-2) = -2 + 2 = 0

var = var - var;

At this stage, the value of var is 0

Answer Link

Otras preguntas

In the equation t = d/6+3 what is the value of t when d =12
Which phrase best describes the tone of this poem on my first daughter by ben Jonson
What is the following product of sqrt 10 times sqrt 10
if the product of two positive numbers is 18, and 1 number is 7 greater than the other, what are the two numbers?
Sunny's garden has 9 tomato plants, 5 pepper plants, 3 squash plants, and 6 pumpkin plants. For every 3 tomato plants in Sunny's garden, there is 1 _
Miriam makes 214 gallons of punch for a school event. How many 4‐ounce servings of punch can she serve ?
How does the polar jet stream move from summer to winter?
Why does algernon call his visit great success although jack is infuriated
The line represented by y = 3x − 6 and a line perpendicular to it intersect at R(3, 3). What is the equation of the perpendicular line? A)y=-1/3x +4 B)y=1/3x +
Find the volume of the given prism round it to the nearest tenth, 6 cm, 3.9 cm, 13.2 cm