Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Valid variable names

  1. Sep 10, 2013 #1
    Hi all, I would like to clarify regarding valid variable names. Well what I fairly understand are the rules regarding names.. What I am unsure about is -- in a test, is there any way to spot a reserved name? For example to make things difficult, trick question, sometimes the question will include

    main
    print
    System
    Int

    etc. usually in a test we dont have the list of reserved words
     
  2. jcsd
  3. Sep 10, 2013 #2

    Mark44

    Staff: Mentor

    You need to be a bit more specific. What language are you asking about? Different languages have different sets of reserved words that can't be used as variable names.
     
  4. Sep 11, 2013 #3
    Regardless of the programming language, if they gave you the list of reserved words and ask you to spot them in the list, that wouldn't be much of test, would it? If you are supposed to be learning a programming language, I presume they expect you to study its reserved words and memorize them; also, to be aware whether the programming language is case-sensitive or not.
     
  5. Sep 11, 2013 #4

    jim mcnamara

    User Avatar

    Staff: Mentor

    Looks like C to me.

    The list of keywords/reserved words in C is short. All of them are lowercase. The C standard (C11)
    from what is usually called N1570:
    N1570 Committee Draft — April 12, 2011 ISO/IEC 9899:201x:
     
  6. Sep 25, 2013 #5

    harborsparrow

    User Avatar
    Gold Member

    One reason programmers like to use an integrated development environment, or IDE, (rather than a simple command window) when writing code, is that the IDE's code window will highlight reserved words in a different color, so it is immediately apparent.

    If it isn't possible to get an IDE or syntax-highlighting editor for you language, then you must simply memorize (or keep a list of handy) that language's reserved words. There can be a lot of them, so an IDE is the best solution if you can get it.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Valid variable names
  1. Ambiguous name (Replies: 5)

Loading...