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 ?    94 Yes 25 No

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

Answer / dhanashree

if x=1 then output will be 4

Is This Answer Correct ?    32 Yes 14 No

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

Answer / lakshmi

If x=4 then answer is 10

Is This Answer Correct ?    29 Yes 12 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 ?    20 Yes 5 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 / 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 ?    10 Yes 5 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 ?    32 Yes 29 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 ?    3 Yes 3 No

Post New Answer



More C Interview Questions

void main() { int i=5; printf("%d",i++ + ++i); }

21 Answers   ME,


plssssss help !!....using array.. turbo c.. create a program that will accept number of words to be consored. .a word must not exceed 10 characters long .the text to be entered will be no longer than 200 characters .there will be no 10 words example: enter number of words to be censor: 5 enter words to censor: windows office microsoft bill gates enter text to censor: bill gates founded microsoft and makes office and windows sample output: <consored> <censored> founded <censored> and makes <censored> and <censored>

1 Answers  


#include<stdio.h> int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

0 Answers  


what is constant pointer?

3 Answers  


When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it?

2 Answers   Aloha Technology,






Write a program to print a (*)pattern programming (A to Z) in capital in one programming ?

2 Answers   TCS,


c program to input values in a table(using 2D array) and print odd numbers from them

1 Answers  


list the no of files created when c source file is compiled

9 Answers   TCS,


write a recursive program in'c'to find whether a given five digit number is a palindrome or not

2 Answers  


Explain demand paging.

1 Answers  


If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.

12 Answers   Google,


Hai friends im a i year student. i want to develop my knowledge in the field of TSR in c. How I'm Improve ?

2 Answers  






Categories