Principles of Computer Programming Languages - Summary
1. What is Computer Programming?
Computer programming languages, like any other language, have grammar (syntax) and rules.
We use them to write instructions that computers can understand and execute.
2. Programming Basics You Must Know:
* Environment Setup: You'll need a text editor (e.g., Notepad), a compiler (for languages like C
or Java), or an interpreter (for languages like Python).
* First Program (Hello World): This is a simple code snippet that displays output on your screen.
3. Elements of a Programming Language
* Variables: Names given to memory locations to store values like numbers or text.
* Data Types: These tell the computer the type of value (integer, float, character, string, etc.).
* Operators: Symbols like +, -, *, / that help with calculations or comparisons.
* Keywords: Reserved words like "int," "float," "if," and "while" that cannot be used as variable
names.
4. Decision Making in Code
Use "if," "if-else," "if-else if-else," or "switch" statements to check conditions. For example: If a
student's score is above 95, print "Brilliant"; if it's below 30, print "Poor"; otherwise, print
"Average."
5. Loops (Repeating Code)
* While Loop: Repeats until a condition becomes false.
* Do-While Loop: Repeats at least once before checking the condition.
* For Loop: Another way to repeat code.
6. Printing & Comments
Use functions like printf() in C, System.out.println() in Java, or print() in Python to display
1
output. Use comments (/* comment */ or // comment) to explain code, which the computer
will ignore.
7. Java & Python Differences
* Java: Requires semicolons and explicit variable type declarations.
* Python: Does not require semicolons, and variable types are inferred.
8. Summary Table: Sample Code Snippets
9. Numbers & Characters
Numbers can be whole (integers), decimal (floats), etc. Characters are single letters or symbols
like 'a', '1', or '*'.
10. Final Words
Programming is like learning a new language. Practice regularly, and you'll become proficient in
communicating with computers.