KCC's Quizzes AQQ306 about a fish stick challenge
1. First the quote of the month: " I am so clever that sometimes I don't understand a single word of what I am saying" - Oscar Wilde
2. New quiz AQQ306 about a fish stick challenge:
Here below is a pseudo fish diagram swimming to the right.
Question
View All
October Monthly Blog Quiz! Read the blog, take the quiz, and you could win a gift card
Finding Your Circuit Chi — EMC Quiz!
Think you know EMC? Test your knowledge with our 5-question quiz!
Read the blog first, then take the challenge: Finding Your Circuit Chi
Every current flowing creates electromagnetic fields.
Strong EMC design
View All
And here is a new challenge for the week:
1. Quote of the week: "Well done is better than well said." - Benjamin Franklin.

2. New quiz of the week: AQQ257 about a C programming puzzle (proposal from our colleague Mirza Kolakovic:

Questions:
Good luck!
a+++++b can be written as
(a++)+(++b), value of a is used and then incremented by 1, value of b is incremented by 1 and then used.
at the time of execution, c= a+(1+b)
after execution, a= a+1 and b= b+1
a++ + ++b will become a+(b+1)
After operation the operand will be a= a+1 and b= b+1
I am taking random integer a and b and assigning some values
Assume a = 2, b = 3 then the expression will go like this a++ + ++b
And a++ is postfix operation and ++b is prefix operation so the value will go like this a= 2 and b = 4 so answer will be 6.
And after this operation a++ will execute and a will become 3 and b will become 4.
The statement a+++++b is effectively a++ (a post increment) + (add) ++b (b pre increment)
So the result will be a + (b+1)
After the execution of the operation, both operands will have been incremented, i.e. a = a+1 and b = b+1
1. The result of (a++)+(++b) which is (a+b)+1
2. a and b would been increased by one.
i++ icreases i by one first after having used it,
4 + i++ results in:
first makes 4 + i
next icreases i by 1.
While 4 + ++i in:
first increases i by 1
next makes 4 + i
Since I'm not fluent in C++, I solicited the help of my son, who is a sophomore CS major, and this was his reply... (feel free to not include me in any solutions since I didn't come up with it. However, I played a part in making him, so I feel that I contributed to the solution at least in some way. )
My guess: assuming a and b are integers…
a+++++b can be rewritten as (a++) + (++b)
Which means the full expression returns the value a + (b + 1)
Reason is because doing ++b increments b first and returns b plus one, while doing a++ increments a but returns the original value (a)
The value of the operands afterward are both just incremented by one
Is this accurate?
Brian
Correct , Congratulations!
I give you hereunder the more detailed answer from our colleague Mirza Kolakovic who had proposed this quiz:
In C, the expression a++ + ++b means increment b, add to a, then increment a. If a and b equal 1 then the expression evaluates to 3 and both variables end up with the value 2. In most other languages it would generate an error message, and quite right too.
Thank you Sona22 ; you are right! I also give you here under the detailed answer from our colleague Mirza Kolakovic who had proposed this quiz:
In C, the expression a++ + ++b means increment b, add to a, then increment a. If a and b equal 1 then the expression evaluates to 3 and both variables end up with the value 2. In most other languages it would generate an error message, and quite right too.
Bingo Martin! I give you also the detailed answer from our colleague Mirza Kolakovic who had proposed this quiz (I am quite weak in software...):
In C, the expression a++ + ++b means increment b, add to a, then increment a. If a and b equal 1 then the expression evaluates to 3 and both variables end up with the value 2. In most other languages it would generate an error message, and quite right too.
Correct vanderghast ! Cong
In C, the expression a++ + ++b means increment b, add to a, then increment a. If a and b equal 1 then the expression evaluates to 3 and both variables end up with the value 2. In most other languages it would generate an error message, and quite right too.
ratulations. I give you also hereunder the detailed answer from our colleague Mirza Kolakovic who had proposed this quiz:
Your answer is correct and fully accurate brianb0722 ! Congratulations to you and to your colleague too! I also give hereunder the detailed answer from Mirza Kolakocic who had proposed this quiz:
In C, the expression a++ + ++b means increment b, add to a, then increment a. If a and b equal 1 then the expression evaluates to 3 and both variables end up with the value 2. In most other languages it would generate an error message, and quite right too.
By the way, I am like you; I am quite light in software...