UINT i,j;
i = j = 0;
i = ( i++ > ++j ) ? i++ : i--;
explain pls....
Answers were Sorted based on User's Feedback
Answer / raj
1.we know that i=j=0 initially
2.then it will checks the non-incremented 'i' value(i.e 0)
with incremented 'j' value(i.e 1). So obviously condition
is falls.
3.now false statement has to be executed i.e (i--),before
executing this 'i' value is (i.e incremented value)'1'
after executing false condition(i.e i--)the value of 'i'
becomes '0'.
4.So the value of 'i' is '0'.
Is This Answer Correct ? | 30 Yes | 2 No |
Answer / vignesh1988i
UNIT i,j :
this line indicates that UNIT is an user defined data type. it may been declared as follows :
typedf int UNIT
we are making the code more readable
i=j=0 : indicates that the var. i and j are declared as 0
i=(i++>++j) ? i++ : i-- : the process here is
i++ is an post incrementation . if this is compared with any relational or any operaters first that value will be operated first and the 'i' will get incremented ........
but ++j if we take first thing it will increment the value and then operation will be performed
so when it is compared first i will be 0 and j will be 1 so 0 is not greater than 1. so false, so it will go to the statement after ':' so i-- is there so final value of i will be 0.
thank u
Is This Answer Correct ? | 6 Yes | 1 No |
Answer / dhatchina moorthy
r u guys nuts the person answered first is right.he
non-incremented 'i' value(i.e 0)
with incremented 'j' value(i.e 1). So condition
is falls.
so false part has to be executed i.e (i--),before
executing this 'i' value is (i.e incremented value)'1'
after executing false condition(i.e i-- her it doesn't
increment bcoz it is postfix operator)the value of 'i'
becomes '1'.
still having doubts, compile this program in ur pc.
Is This Answer Correct ? | 5 Yes | 1 No |
Answer / prem_mallappa
All answers are incorrect except this one.
Read c-faqs (Frequently asked questions about C)
The answer is unpredictable or implementation defined.
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / chaneswara reddy
(i++ > j++) gives 0 because 0 > 0 is false so it return 0.
before returning 0 i is 1 ,but it is overwrite by 0.
In the Conditional operator false means ,it executes i++;
so i is 1.
Is This Answer Correct ? | 3 Yes | 19 No |
Given that two int variables, total and amount , have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount , one at a time. After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). Instructor's notes: If you use a loop, it must be a for loop. And if you use a loop control variable for counting, you must declare it.
Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?
how to convert decimal to binary in c using while loop without using array
50 Answers Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,
void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....
Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.
What is the out put of this programme? int a,b,c,d; printf("Enter Number!\n"); scanf("%d",&a); while(a=!0) { printf("Enter numbers/n"); scanf("%d%d%d",&b,&c,&d); a=a*b*c*d; } printf("thanks!"); getche(); Entering numbers are a=1,b=2,c=3,d=4 b=3,c=4,d=-5 b=3,c=4,d=0
wap for bubble sort
what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?
quoroum of computer languages?
write the value of x and y after execution of the statements: int x=19,y; y=x++ + ++x; x++; y++;
How to reverse a linked list without using array & -1? Thank you.
what is the large sustained error signal that eventually cause the controller output to drive to its limit