Computers and Technology
03.02.2021 07:52
134
265
7
Solved by an expert

When dealing with perspective, lines are used or implied.

When dealing with perspective, lines are used or implied.
Show Answers
sanm378599
sanm378599
4,9(28 marks)

I'm pretty sure the answer is vanishing lines.

Explanation:

cyndy50
cyndy50
4,4(27 marks)
Iam not an expert, but i am somewhat familar with incrementation and decrementing variables.

also, i've done my research from some documentation and  stackexchange answers. there is a problem with the question and what it uses.

in the line

    a = ++a + ++a;
it is altering the same variable more than once in a single  expression.
in c, this is considered  undefined behavior. different compilers will evaluate this line differently. you cannot get a definite answer.  you will not see code like that in a real-life program. you are discouraged from writing code like that.

google up terms such as "increment decrement operator multiple" if you want to read more about this. you should probably bring that "a=++a + ++a; " line up with your teacher after doing some research of your own.

i will present some sort of assumption in my explanation when we come across that line. the explanations afterward involving different variables in a statement using ++ and -- should be definite and logical.



consider the line of code

{
    int a = 10
    int msg = 5 + a++;
    print msg, a;
}

the output will be 15 and 11 (in other words, msg is 15 and a is 11)
a++  will increment  after it is used in a statement.

the value used for "a++" in the line of cone is 10, not incremented. then after that line of code, the value of a will be increased by 1.



consider the line of code
{
    int a = 10
    int msg = 5 +  ++a;
    print msg, a;
}

the output will be 16 and 11 (in other words, msg is 16 and a is 11)
++a will increment  before  it is used in a statement.

the value of  a gets increased by 1 before it is used in the statement. so the actual math here is 5 + 11.



also, seeing -- has the same behavior, except it will decrement a variable by 1.

so --variable decrements the variable before it is used and
variable-- decrements the variable after it is used.



let us go through the example code step-by-step.

    int a=10,b=5;
    a = ++a + ++a;
i've mentioned at the top that the second line is an undefined statement, where different c compilers will yield different results.
i guess in this case
    a  =  ++a + ++a;

will have the final value of a be 24. my guess is that it will increment the variable a twice before the statement is even run; what actually gets added up is (10+2) + (10+2) = 24. again, it is bad code. 
this next batch of code is more workable; it is not incrementing/decrementing a variable multiple times in one line.
before the code below, we have a=24 and b=5.
    b = a-- - --b;

the a-- means that a will be decremented after it is used in the statement. so what is actually used for a--  in the statement is 24, not 23. it is only after that line of code when a becomes 23. 

the --b means that b will be decremented before it is used in the statement. so what is actually used for --b in the statement is 4. it decremented the initial value of 5 before it used it.

so the actual math of that line becomes b = 24 - 4, which is 20.

after that line, the value of a at 24 is decremented by 1 to become 23.

thus making the output 23 and 20.

i hope this you.
and you really should bring that problematic line up with your teacher.

Popular Questions about the subject: Computers and Technology

What is your age and we can do zoom...
Computers and Technology
21.05.2022 07:28
Create a function called intpoly( ) that can numerically integrate...
Computers and Technology
15.05.2023 13:10
You recieved $50 as a birthday gift and choose to spend it on...
Computers and Technology
07.09.2022 18:16
Do people answer questions more on this site or be on social...
Computers and Technology
20.10.2020 08:36
To connect to a network, you need a card...
Computers and Technology
06.12.2022 23:46
The most common software for creating text documents is software...
Computers and Technology
20.01.2022 07:14

New questions by subject

If a = x+21, b = 8, c = x + 4, and d = 10, then the value of...
Mathematics
16.11.2020 04:23
The baseball team has never lost a match in its home ground....
Social Studies
22.04.2023 03:04
#
#
#
#
# #

We expand our knowledge with many expert answers