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 / sadashiv

these type of expression evaluation is dependent on
compiler

if u use turbo c and x =1;

then answer would be
main();
int x=1,y.
y = x++ + ++x.
printf /n'%d',y.
here y = 4

Is This Answer Correct ?    143 Yes 32 No

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

Answer / lakshmi

If x=4 then answer is 10

Is This Answer Correct ?    44 Yes 13 No

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

Answer / dhanashree

if x=1 then output will be 4

Is This Answer Correct ?    41 Yes 16 No

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

Answer / manojkumar

I have worked out this.in turbo c3
#include<stdio.h>
#include<conio.h>
void main()
{ clrscr();
int x,y;
x=4;
printf("%d",x++ + ++x);
getch();
}

output:
10

Is This Answer Correct ?    23 Yes 5 No

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

Answer / debashree

#include<stdio.h>
int main()
{
int x=1,y;
y=x++ + ++x;
printf("y=%d\n",y);
return 0;
}
o/p->
y=4

Is This Answer Correct ?    17 Yes 7 No

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

Answer / dushmanta

it will gives u a garbage value according to u r compiler

Is This Answer Correct ?    15 Yes 9 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 ?    34 Yes 30 No

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

Answer / shashi shekhar

In this type of question the operation done from right side of the expression.Here we can see two types of increments pre and post increment,in post first the value assigned then increment but in pre first the value is incressed then the value assigned.

For example if x is initialized with a value
"1" then the this expression gives the output "4".

Is This Answer Correct ?    4 Yes 2 No

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

Answer / shivu

4

printf or any other expression executes from right. So first
prefix increment. then 2 and assigned to y. and will get add
with the result again, then it will increment.
now the value of x is 3. but the output is 4.

Is This Answer Correct ?    1 Yes 0 No

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

Answer / prem

if x=3
y=x++ + ++x;
y will be 8
x will be 5

calculating y part
1) x++ is 3 and x will be 4
2)++x is 5 bcz x is incremented then assigned so x=5

so y finally gives 8.

Is This Answer Correct ?    4 Yes 4 No

Post New Answer

More C Interview Questions

How can I increase the allowable number of simultaneously open files?

1 Answers   ABC,


Is c still used?

0 Answers  


The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none

0 Answers  


how to find turn around time in operating system?

3 Answers  


write a program that eliminates the value of mathematical constant e by using the formula e=1+1/1!+1/2!+1/3!+

1 Answers   Reliance,






In C programming, what command or code can be used to determine if a number of odd or even?

0 Answers  


Write a program to print the following series 2 5 11 17 23 31 41 47 59 ...

2 Answers  


What is wrong with this program statement?

0 Answers  


Write a c program to read a positive number and display it in words.? ex: 123=one two three help me....

2 Answers  


program for reversing a selected line word by word when multiple lines are given without using strrev

0 Answers   IBM,


How many levels of pointers can you have?

0 Answers  


What is string concatenation in c?

0 Answers  


Categories