0

I want to know the logic to the questions in the challenges.. I means. if x = 4;S. o. t("++x"); output : 5 . hope u understand..

I need help in in very commonly know conditon when we have challenge in any language 1 win and 1 lose and sometimes draw.when we lose it means we don't have correct answers but I need to know the logic for the answer. simply I want to know why that question have the answer 5..so it is because ++ operas simply means 1 hence ,simply add 1. hence there are many questions in challenges whose answers are out of my exceptions hence I want the logic.. please help.is there any way.

4th Jan 2018, 6:17 AM
Anjali Kushwaha
Anjali  Kushwaha - avatar
6 Respuestas
+ 7
++x defines the preincrement means first assign the value n then increment as we see there is no eq who follows ++x for ex (b=++x) at that case first assigned the value of x to be then increment value of x by 1 ....so it this question only ++x so in case x is increment by 1 ie 5 ...I hope your concept is clear now!!!!
5th Jan 2018, 8:59 AM
Aditya Singh
Aditya Singh - avatar
+ 7
okey all questions logic can't be explained if you feel doubt n problem in question just take a screen shot n try to debug this code on PC you get to know the logic by writing code itself...
6th Jan 2018, 6:01 AM
Aditya Singh
Aditya Singh - avatar
+ 2
x++ returns X and then adds 1 to x. The return value is the original X. ++x adds 1 to X and then returns it. The return value is the original X + 1.
4th Jan 2018, 1:07 PM
Lil Taco
Lil Taco - avatar
0
thank u but that not my question I am sorry I didn't made u understand my question
6th Jan 2018, 5:34 AM
Anjali Kushwaha
Anjali  Kushwaha - avatar
0
I want to say that I want to know the logic for all the questions in the challenges
6th Jan 2018, 5:34 AM
Anjali Kushwaha
Anjali  Kushwaha - avatar
0
System.out.print("++x") will print ++x as a string if it was System.out.print(++x) then the outpur will be 5
1st Apr 2018, 8:30 AM
Ashish Kumar Tiwari