C Language Problem Please Explain Show which of the followin

C Language Problem

Please Explain

Show which of the following are valid and which are invalid identifiers: Why? run_1 2run double Char double-trouble two-four

Solution


Rules For Constructing Variable Name
Characters Allowed :
   Underscore(_)
   Capital Letters ( A – Z )
   Small Letters ( a – z )
   Digits ( 0 – 9 )

   Blanks & Commas are not allowed
   No Special Symbols other than underscore(_) are allowed
   First Character should be alphabet or Underscore
   Variable name Should not be Reserved Word

Answer:
   run_1 : valid   

   2run: Invalid => identifier name can not start with digit

   double : Invalid => it is keyword in C

   Char : valid

   double-trouble :Invalid => identifier name can not contains \'-\' character

   two*four : Invalid => can not contain *

C Language Problem Please Explain Show which of the following are valid and which are invalid identifiers: Why? run_1 2run double Char double-trouble two-fourSo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site