Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


UINT i,j;
i = j = 0;
i = ( i++ > ++j ) ? i++ : i--;

explain pls....

Answers were Sorted based on User's Feedback



UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls......

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

UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls......

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

UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls......

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

UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls......

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

UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls......

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

Post New Answer

More C C++ Errors Interview Questions

full c programming error question based problem

3 Answers   HCL, TCS,


I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00

3 Answers   UCB,


Write a C program to enter 10 integer numbers through one variable and count how many of them are even using while loop ?

2 Answers  


How to create a program that lists the capital country when told what the original country is? (Terribly sorry, I'm a novice programmer and would appreciate any help ;). Cheers, Alexxis

0 Answers  


How to develop a program using C language to convert 8-bit binary values to decimals. TQ

1 Answers   Amazon,


void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?

24 Answers   HCL,


char* f() return "hello:"; void main() {char *str=f(); }

1 Answers  


who was the present cheif governor of reserve bank of india

6 Answers   State Bank Of India SBI,


Why are memory errors hard to debug?

1 Answers  


what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }

4 Answers  


To generate the series 1+3+5+7+... using C program

18 Answers  


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

14 Answers   HCL,


Categories