What will be the output of
x++ + ++x?

Answers were Sorted based on User's Feedback



What will be the output of x++ + ++x?..

Answer / naveenkumari

here we can see two types of increments pre and post
increment . since x++ is post increment first the value is
assigned and then increments but in case of ++x first the
value is incremented and then assigned since x is not
initialized with any value the above expression gives a
garbage value .For example if x is initialized with a value
"1" then the this expression gives the output as "3"

Is This Answer Correct ?    4 Yes 4 No

What will be the output of x++ + ++x?..

Answer / sujan

let x=1,here it starts with x++, so first x takes value 1 and then it increments to 2.. later ++x.. here x is incremented first i.e.,x=3 and then added to previous value..ie., 1+3
o/p is 4

Is This Answer Correct ?    1 Yes 1 No

What will be the output of x++ + ++x?..

Answer / sairoong.l@drsomchai.net

Test Sairoong

Is This Answer Correct ?    0 Yes 0 No

What will be the output of x++ + ++x?..

Answer / sairoong.l@drsomchai.net

static void Job13(Args _args)
{
Dialog dlg;
DialogField dlgField;
;


dlg = new Dialog("test");
dlg.addGroup("test");
dlgField = dlg.addField(TypeId(CustAccount), "test");

if(dlg.run())
info(dlgField.value());


}

Is This Answer Correct ?    0 Yes 0 No

What will be the output of x++ + ++x?..

Answer / santhi perumal

Answer is 2x+2. For Ex: if x is 2 result is 2(2)+2 = 6.

Is This Answer Correct ?    7 Yes 8 No

What will be the output of x++ + ++x?..

Answer / vaibhav

if x=4 then o/p will be 9

Is This Answer Correct ?    2 Yes 3 No

What will be the output of x++ + ++x?..

Answer / srinivas

for this what is the input value of x.First of all we have
to give the input value of x.
if x = 1 then answer would be
main();
int x=1,y.
y = x++ + ++x.
printf /n'%d',y.
here y = 3

Is This Answer Correct ?    11 Yes 15 No

What will be the output of x++ + ++x?..

Answer / pardeep

answer illl always be 4
value of x ill be 2+2
it willincrement only in 2nd case th ++x

Is This Answer Correct ?    4 Yes 13 No

What will be the output of x++ + ++x?..

Answer / mortal

x++ starts with x and ++x starts with x+1,hence if x=1 then
ans. is 3.

Is This Answer Correct ?    5 Yes 15 No

What will be the output of x++ + ++x?..

Answer / vaibhav

suppse if x=5,
then o/p will be 13

Is This Answer Correct ?    4 Yes 16 No

Post New Answer

More C Interview Questions

What is c value paradox explain?

0 Answers  


What is c basic?

0 Answers  


How can I implement sets or arrays of bits?

0 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

0 Answers   IBM,


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

0 Answers  






What should malloc() do?

0 Answers  


using for loop sum 2 number of any 4 digit number in c language

0 Answers  


HOW TO SWAP TWO NOS IN ONE STEP?

16 Answers   Satyam,


Convert the following expression to postfix and prefix (A+B) * (D-C)

3 Answers   Satyam,


Write a program to reverse a given number in c?

0 Answers  


How many types of operators are there in c?

0 Answers  


who did come first hen or agg

15 Answers   Infosys,


Categories