#include #include #include int main (int argc, char **argv); int count (int n); int main (int argc, char **argv) { int x, y, z; x = 5; y = x < 0 ? 27 : 14; /* ternary operator ?: */ /* a?b:c if a is true answer is b. if a is false answer is c. */ printf ("%d\n",y); /* C's print statement */ z = (27,103); /* The comma operator computes the expression left, discards it, computes and returns the expression on the right. */ /* In C, EVERYTHING is based on order of operations. * / % take precedence over + - But there's a whole slew of other things. == != < > <= >= are operators as well. In C, these operators return an int (1 if true, 0 if false). In C, you can say Z = x < y; That will set Z to 1 if x really is less than y and 0 if it is not. && || have specific precedence. z = x +++ y; Does it mean (x++) + y or does it mean x + (++y)? I think it's the first...Moral: don't do this, no one can understand it. & | ^ have precedence. The assignment = also is a mathematical operator and it has a certain precedence in the order of operations. x = y sets x to the value of and then returns the value of x. In C, you can say z = x = y = m+7; = is one of the lowest priorities, but it is not the lowest. , is lower than =. x = 27,14 The x=27 gets evaluated first, so x gets set to 27. then 27 is thrown away, and the expression is evaluated to 14. But since the 14 isn't used in any way, the 14 then gets thrown away as well. */ printf ("%d\n",z); printf ("%d\n",(z=102,5)); printf ("%d\n",z); z = (1,2,3,4,5,6,7,8,9,10); printf ("%d\n",z); count (22); return 0; } /* This will be a functional method */ int count (int n) { return ( (n>0)? (count(n-1),printf ("%d\n",n)):0); }