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 ?    87 Yes 23 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 13 No

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

Answer / lakshmi

If x=4 then answer is 10

Is This Answer Correct ?    28 Yes 11 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 ?    19 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

Write a program to print all the prime numbers with in the given range

8 Answers   TCS, ABC, College School Exams Tests,


write a c program to calculate the income tax of the employees in an organization where the conditions are given as. (I.T. = 0 if income <100000 I.T = 10% if income _< 200000 it = 20% if income >_ 200000)

6 Answers   Satyam, FD, JK Associates, Kobe, Consultancy, DBU,


read a number & print all its devisors using c-program?

3 Answers  


what is develop in c language

2 Answers  


why programs in c are running with out #include<stdio.h>? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

0 Answers  






nic scientist exam

1 Answers   NIC,


Give a method to count the number of ones in a 32 bit number?

4 Answers  


how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?

0 Answers  


Given a piece of code int x[10]; int *ab; ab=x; To access the 6th element of the array which of the following is incorrect? (A) *(x+5) (B) x[5] (C) ab[5] (D) *(*ab+5} .

2 Answers   Oracle,


how to add two numbers without using arithmetic operators?

4 Answers  


given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the array which of the following is incorrect? a.*(a+5) b.a[5] c.pa[5] d.*(*pa + 5)

6 Answers   TCS, amu,


void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s",env[i]); }

3 Answers  






Categories