Programming and Portability Tips
 

Editor-in-Chief  :

Prof. Riazuddin

Editorial Board  :      

Fawad Saeed (IT)

 Adeel-ur-Rehman(IT)

 M. Jamil  Aslam(Physics)

 Ijaz Ahmed(Physics)

 
  • Always initialize counters and totals.

  • Declare each variable on a separate line.

  • Unary operators should be placed next to their operands with no intervening spaces.

  • Control counting loops with integer values.

  • Indent the statement in the body of each control structure.

  • The keystroke combinations for entering end-of-file are system dependent. i.e. Ctrl + D for Linux and Ctrl + Z for Windows.

  • Testing for the symbolic constant EOF rather than -1 makes programs more portable. The ANSI standard states that EOF is a negative integer value (but not necessarily -1). Thus EOF could have different values on different systems.

  • Because ints vary in size between systems use long integers if you expect to process integers outside the range -32768 to +32767 and you would like to be able to run the program on        several different computer systems.

  • For compatibility with earlier versions of C++ standard, the bool value true can also be represented by any non-zero value and the bool value false can also be represented as the value 0.