Skip to content
Question Bank (5 marks) · Q6

Q.Write the rules for forming variable name.

Karnataka PUCTextbookLong· 5mImportance★★★★★est
21% · 33/154 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

[!TLDR]

A variable name starts with a letter/underscore, uses only letters/digits/underscore, is not a keyword, has no spaces, is case-sensitive, and must be declared before use.

A variable is a named location in memory whose value may change during execution. The rules for forming a valid variable name are:

  1. The first character must be an alphabet (A-Z, a-z) or an underscore ( _ ).
  2. The following characters may be letters, digits (0-9) or the underscore.
  3. No blank spaces and no special characters (other than the underscore) are permitted.
  4. Keywords must not be used as variable names.
  5. Variable names are case-sensitive - Total and total are different.
  6. The name should be meaningful, and it must be declared with its data type before it is used.

Examples:

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.