Keywords in C
www.cinterviews.com appreciates your contribution please mail us the questions you have to cinterviews.blogspot.com@gmail.com so that it will be useful to our job search community
Each of the types shown in Table 3-1 (i.e., boolean, char, int, etc.) are keywords in C. A keyword is any word
that has special meaning to the C compiler. Because keywords are reserved for the compiler’s use, you
cannot use them for your own variable or function names. If you do, the compiler will flag it as an error. If
the compiler didn’t flag such errors, then the compiler would be confused as to which use of the keywords
to use in any given situatin.
Table 3-1. C Value Data Types
Variable Names in C
If you can’t use keywords for variable or function names, then what can you use? There are three general rules for naming variables or functions in C: Valid variable names may contain:
If you can’t use keywords for variable or function names, then what can you use? There are three general rules for naming variables or functions in C: Valid variable names may contain:
-
Characters a through z and A through Z
-
The underscore character (_)
-
Digit characters 0 through 9, provided they are not used as the first character in
the name.
jane Jane ohm ampere volt
money day1 Week50 _system XfXf
Using the same rules, the following would not be valid names:
^carat 4July -negative @URL
%percent not-Good This&That what?
Given these limits, how does one create a “good” variable name? As a general rule, variable
names that are long enough to give me a clue as to what they do in a program but short enough that don’t
get tired of typing their name. Another convention a lot of programmers used is a variant of what’s called
camel notation. Using this notation, variable names begin with a lowercase letter with each subword
capitalized. Examples using this style might be:
myFriend togglePrinter reloadEmptyPaperTray closeDriveDoor
you will write perfect (error-free) code every time you write a
program. Using variable names that make sense and are easy to read makes debugging just that much
easier. ( C is case sensitive, which means that myData and MyData are two different
variables).
No comments:
Post a Comment