Correct The Code.

Correct The Code.

These kind of questions come as two-markers mostly.
Now, normally... 2 marks isn't worth considering
but when you're trying to pass, every point matters.

EXAMPLE:

Board Q [2008]: Correct the following program.

You'll need to know a number of stuff
and I've jotted down a few main ones

1) THE CODE IS CASE-SENSITIVE.

(All the Coding in c++ should be lower case. {a} )

( Variables however may possess Upper case characters. {A} )

Here's a question which tends to come quite frequently: 

int ConUp;

cout<<Conup;

  Case Sensitive.
The variable Conup has not been initialized.

Conup & ConUp 
( Are considered Two different variables. )


2) NAMING OF VARIABLES/IDENTIFIERS.

. . . . CAN NOT contain a special character. . . . 

char First-name[20];
char First@name![20];

You may use underscore
and only underscore:

char First_name[20];


 . . . . CAN NOT start with a number. . . .

int 92s;

int 1to5;

You may use it after alphabets.

int n2;
int a2z;

The following is also Correct:

int _No;

 . . . . CAN NOT be a Keyword. . . .

int class
int int;

However, since all C++ coding is lowercase,
making a letter uppercase makes it Valid.

int iNt;
int Class;

Some Keywords you should wary of:

auto   const     double  float  int       short   struct   unsigned

break  continue  else    for    long      signed  switch   void

case   default   enum    goto   register  sizeof  typedef  volatile

char   do        extern  if     return    static  union    while

_____
asm         dynamic_cast  namespace  reinterpret_cast  try

bool        explicit      new        static_cast       typeid

catch       false         operator   template          typename

class       friend        private    this              using

const_cast  inline        public     throw             virtual

delete      mutable       protected  true              wchar_t

______
and      bitand   compl   not_eq   or_eq   xor_eq

and_eq   bitor    not     or       xor

3) And Others...
Working on them..

Comments