Send Close Add comments: (status displays here)
Got it!  This site "www.robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
C: A first program
by RS  admin@robinsnyder.com : 1024 x 640


1. A first program
Here is a simple Lua program that outputs the text "Hello, World" to the standard output (e.g., screen, printer, file, etc.). Previously, we were only interested in compiling and running the program. Now we want to look at the program structure, what it does, how it does it, etc. Here is the program. Here is the C code [#1]

Here is the output of the C code.


2. Case sensitivity
In file systems, programming languages, etc., a name is often called an identifier as the name is used to identify some idea or concept.

3. Uppercase, lowercase, etc.
All letters have an uppercase and a lowercase version.

4. Names
A name in a programming language is ofter called an identifier is the name "identifies" some concept being used. The case rule for names refers to what types of uppercase and lowercase letters are allowed.

5. Underscores
Many languages permit the underscore character "_" to be used in a name. This would allow the following as named identifiers. Question: Are the identifiers/words "Main" and "main" the same?

6. Minuscule and magniscule
Like traditional security codes, ancient texts had no spaces and only one type of letters.

Languages were not standardized.

7. Charlemagne
Charlemagne, Emperor of the Holy Roman empire, ordered that lowercase letters be created and standardized along with uppercase letters.

At that time, they were called miniscule and magniscule.

The publication of dictionaries standardized the language.

8. Upper and lower case
There are two types of cases for letters: uppercase and lowercase From where did lowercase letters come from?

9. Case sensitivity

10. Case sensitivity
A case sensitive notation means that the following names are all different.
DELETE dELETE DeLETE deLETE DElETE dElETE DelETE delETE DELeTE dELeTE DeLeTE deLeTE DEleTE dEleTE DeleTE deleTE DELEtE dELEtE DeLEtE deLEtE DElEtE dElEtE DelEtE delEtE DELetE dELetE DeLetE deLetE DEletE dEletE DeletE deletE DELETe dELETe DeLETe deLETe DElETe dElETe DelETe delETe DELeTe dELeTe DeLeTe deLeTe DEleTe dEleTe DeleTe deleTe DELEte dELEte DeLEte deLEte DElEte dElEte DelEte delEte DELete dELete DeLete deLete DElete dElete Delete delete

A case insensitive notation would consider the all of the above the same identifiers. In general, try not to use case-sensitive identifiers. I like case-retention with formatter macro issue support to make source consistent.

Information sign More: Case sensitivity

11. Just because
Just because you can do it does not mean you should do it.

A good programming picks a subset of a language and then uses that subset.

If the language has too many ways to do things, such as PHP, different programmers will pick different subsets to use. This can make it difficult for a programmer to work with another programmer's code.

12. URL's
Is a URL (Uniform Resource Locator) case-sensitive?

Example:
http://168.20.203.67/VITA.NV/default.asp

Note: The domain name is not case sensitive, but the path within the domain depends on the web server operating system used.

13. Files
Is a file reference case-sensitive? For example, image.jpg is different than image.JPG on a Linux web server but the same on a Windows web server.


14. Windows file system
The Microsoft Windows file system is case-retentive in that it retains the case of a name, but does not use it for matching purposes.

Thus, image.jpg would match image.JPG. What does it mean to be required to use case-sensitive identifiers? Give a specific example.

The last of these names, delete, might be reserved as a keyword. The others could then be used in a program in a case sensitive language.

How many ways are there to write the word "delete" in a case-sensitive manner where all would be the same if a case-insensitive match were used? How many ways are there to write the word continue in a case-sensitive manner where all would be the same if a case-insensitive match were used? Explain.


15. Programming languages
When programming, does it make a difference which case you use for identifiers? Most modern languages are case-sensitive.

Visual Studio will change the case in the editor to the case of the declaration.


16. Case conventions
The programming language C is case sensitive.

17. C: Reserved words
A reserved word is a word (name, identifier) in the language that has a special meaning and cannot be used in a program as a programmer-defined or library-defined identifier or name except as specified by the rules of the programming language.

18. Reserved words
Here are some reserved words for C.


The reserved words typically covered in a first programming course or in bold.

19. Library identifiers
A library identifier is a word that is part of a code library. It can be redefined, but that might cause problems with the program as it was intended to be run. The word main is a reserved word in C.

The identifier "String" might be what you want.

You type "string".

Will it work?

It might work. There may be library names "string" and "String".

You may get the wrong one and may not notice for a while that it is not the right one.

20. Syntax



21. Incorrect syntax
A syntax of a programming language is comprised of the grammar and punctuation rules for the programming language.

Incorrect syntax: What is the right syntax?

It could be one of the following (or something else). Suppose that you make a syntax error. How can the compiler decide what you meant?

The compiler can only detect errors as inconsistencies.

It is up to you, the programmer, to decide what should be done.

22. Examples of identifiers
An identifier name starts with a letter or underscore and is followed by letters, digits, or underscores.

Examples:
hello hello1 hello2 hello3 helloWorld _hello _hello1 _hello1World Hello_World


23. White space
Notice again the use of blank lines and spaces. In a program, white space is
blank lines and spaces and indentation that is used to make the program more readable.

The term "white space" comes from the fact that if you are using white paper, any space is the color of the paper (i.e., white). The computer does not care. Your boss does. Your professor does. And, you do, if your programs are important to you.

24. Consistency
The most important programming style consideration is to be consistent.

Being consistent means always doing similar things in the same way.

25. White space
Look at the program, again.

Note the following. A subpart should be indented consistently, just as in an outline.

26. Indentation
In most programming languages, there is more than one way to indent. Another way to indent the above program, and a style used by many programmers, is as follows. Which is better? It all depends. The most important thing is that whichever way you chose to indent, be consistent.

Note: To write a good program, you need more than good "indentions"!

27. Detected errors
You should read the error message and make a decision as to what to do.

28. End of page

by RS  admin@robinsnyder.com : 1024 x 640