/*AN IMPLEMENTATION TO SEE WORKING OF CONDITIONAL OPERATOR (?)WITH VARIOUS DIFFRENT TYPES OF OPERATORS(&,&&,|,||,~)..*/
#include<stdio.h>
int main()
{
int x=2,y=1,z=1;
{
printf("%d\n",x<y?x:y);//if condition is true it will print x=2 otherise y=1
//2<1 ..means false ..prints value of y i.e. 1
printf("%d\n",x<y?x++:y++);//2<1 false means prints y=1 post increment in printf function means it will 1st do operation & then ++ments the value of variable////now it prints y=1 & then on made y=2 & also offcourse x=3
printf("%d\n",y);//NOW AFTER OPERATION OF PRINTF ....y=2 WILL BE PRINTED..//
printf("%d\n",z=x<y?x++:y++);//PERFORM CHECK ON 3<2 MEANS FALSE ..IT PRINTS y=2 & then on again ++ments x & y ..now x=4 y=3........value that comes that is output of this conditional statement will also be put into z....so z=2 ////
printf("z=%d\n",z);//z=2 printed
printf("y=%d\n",y);//++mented value of y after printf...y=3 is printed...//
}
{
int x=3,y=z=4;//values are again intialised ..//
printf("%d\n",z<=y>=x?1:0);//THIS WILL CHECK 1ST IF y>=x?1:0 THIS CONDITION WILL GIVE 1 OR 0 :--OFFCOURSE y is greater so this will give output to u 1 BUT AT THE SAME TIME 1 MORE CONDITION IS THERE IS THAT ...IF z<=1 means 4<=1 will give false means zero to u...so NET OUTPUT WILL BE 0.....
printf("%d\n",z=y&&y>=x?1:0);//z=y will assign value of y into z...&& will do logical and with result of condition y>=x?1:0......will be true means 1....so 4 && 1..is true means 1 for logical and..note this is not bitwise and...
//in logical and...if all the values are +ve or -ve but not zero mean to say if all the values are true ..then,..overall output will be true means 1...
//if any of the value become false overall output will also be false....means 0 will be printed