Anyone please explain this???

by 9 replies
11
Here is a series of three steps:

Step 1: A = 10
Step 2: B = 20
Step 3: A = B

A and B are variables, that is they can stand for any value.
The "=" sign stands for assignment. It means "assign the value on the right to the variable on the left".
After all three steps above have been completed, what are the values of A and B? *
A = 30, B = 0
A = 30, B = 20
A = 20, B = 20
A = 20, B = 0
A = 10, B = 10
A = 10, B = 20
A = 20, B = 10
A = 0, B = 10
#programming #explain
  • A=20
    B=20

    The variables will be equal to the last number assigned to them.
  • So where do you go to school?
    • [1] reply
    • If he couldn't figure that out, I don't think he does go to school.
      • [1] reply
    • Banned
      [DELETED]
  • I think I was a bit more subtle than you, in that I pretty much just called him (and I'm going to be subtle again) not very smart.
  • Answer is 3rd Option from the given above list. B is getting assigned to A, since assignment operator is used.
    • [1] reply
    • A = 30, B = 0 <-- i am pretty sure this would return a syntax error
  • Step 3 made the variable constant
    A = 10, B = 20 that is right
    yaser abu sh
  • A=20 and B=20

Next Topics on Trending Feed