a simplek, question. what is identifier ??

N

news.hku.hk

may i ask what is identifier ?
because my teacher said my program have poorly selected identifiers.
 
K

Karl Heinz Buchegger

news.hku.hk said:
may i ask what is identifier ?

a name for something.
An identifier identifies something.
because my teacher said my program have poorly selected identifiers.

He probably ment: You choosed bad names for your variables and/or functions.

Take the code line:

i = e * 0.2;

Can you guess what the above line should do? Neither can I without
analyzing the whole program and figuring out what i and e stand for.

But now I rewrite the whole thing:

TaxRate = 0.2;
PriceToPay = Price * TaxRate;

Can you now guess what is going on? See what a difference
well choosen variable names (aka identifiers) can make?
 
O

osmium

news.hku.hk said:
may i ask what is identifier ?
because my teacher said my program have poorly selected identifiers.

In this context it the names you have slected for the variables.

The names should be slected to give the reader some idea of what the
variable is all about. For example, nbr_students (or some variant) is
certainly better than x and probably better than n.

In more general terms as identifier is the word chosen by the programmer to
identify something or other. That something can be a variable ( as above),
a function, a type (as in class foo), or the label which serves as a goto
destination, ....

It is the thing you learned the spelling rules for early in the course:
starts with a letter, followed by a letter or digit or underscore ....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top