Wednesday, 9 January 2013

C/C++ Puzzles: PART - 18

White Spaces Can Correct Your Program
    
  I still remember the days when I first learned C Programming. One of the first rules I learned was about white spaces in C. "C is a free form language and white spaces will not affect the meaning of the program" was the rule I learned. Up until recently I found this rule perfectly valid. But the following statements shattered my belief. 
   z=x++y;             // This Statement will Give You an Error.
  z=x+  +y;           // This Statement is Correct.

  
   z=x--y;               // This Statement will give you an Error.
  z=x-  -y;             //
This Statement is Correct.
  
  z=x++++y;        // This Statement will give you an Error.
  z=x++  +  +y;   
// This Statement is Correct.
  
  z=x+++++y;      // This Statement will give you an Error.
  z=x++  +  ++y; 
// This Statement is Correct.

There might be other examples similar to this. If you know any please post them here.

No comments:

Post a Comment