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

How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?

1 Answers  


what is the large sustained error signal that eventually cause the controller output to drive to its limit

1 Answers   TCS,


How to convert hexadecimal to binary using c language..

1 Answers   Bajaj, GAIL, Satyam, Zenqa,


A sample program using data structure? what is file handling?

0 Answers   TCS,


#include<stdio.h> void main() { int i=1; printf("%d%d%d",i++,++i,i); }

19 Answers  






Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,


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

1 Answers  


2. A student studying Information Technology at Polytechnic of Namibia is examined by coursework and written examination. Both components of assessment carry a maximum of 50 marks. The following rules are used by examiners in order to pass or fail students. a. A student must score a total of 40% or more in order to pass (total = coursework marks + examination marks) b. A total mark of 39% is moderated to 40% c. Each component must be passed with a minimum mark of 20/50. If a student scores a total of 40% or more but does not achieve the minimum mark in either component he/she is given a technical fail of 39% (this mark is not moderated to 40%) d. Grades are awarded on marks that fall into the following categories. Mark 100-70 69-60 59-50 49-40 39-0 Grade A B C D E Write a program to input the marks for both components (coursework marks out of 50 and examination marks out of 50), out put the final mark and grade after any moderation. [30]

0 Answers  


Using string functions write a program that will accept the name of the capital as input value and will display the corresponding country. ------------------------ Capitals Countries ------------------------ Capitals Countries Ottawa Canada Moscow Russia Rome Italy I can't not get it to run properly

1 Answers   AMA,


full c programming error question based problem

3 Answers   HCL, TCS,


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

5 Answers   TCS,


what is syntax error?

3 Answers  


Categories