What will be the output of
x++ + ++x?
Answers were Sorted based on User's Feedback
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 ? | 144 Yes | 32 No |
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 |
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 |
Answer / dushmanta
it will gives u a garbage value according to u r compiler
| Is This Answer Correct ? | 15 Yes | 9 No |
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 |
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 |
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 |
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 |
will the program compile? int i; scanf(ā%dā,i); printf(ā%dā,i);
How do you determine the length of a string value that was stored in a variable?
What is return in c programming?
I need previous papers of CSC.......plz help out by posting them.......
What is a program?
What are the commands should be given before weiting C Program i.e, Cd.. like
4 Answers IBM, Infonet, Satyam, Tech Mahindra,
What does c mean before a date?
struct node {struct node*temp,*new} prinf("%d",sizeof(struct node));
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
`write a program to display the recomended action depends on a color of trafic light using nested if statments
how to write optimum code to divide a 50 digit number with a 25 digit number??
how to swap two integers 1 and 32767 without using third variable