COMPUTER PROGRAMMING LANGUAGE
Meaning of Computer Programming Language
A computer programming language is a special language used to give instructions to a computer so that it can perform specific tasks. These instructions are written in a way that the computer can understand and execute.
In other words, a programming language allows humans to communicate with a computer. It helps you to tell the computer what to do, step by step, to solve problems, run applications, or carry out calculations.
Without a programming language, computers would not understand human instructions, as they can only process binary code (0s and 1s).
Importance of Programming Languages
Programming languages are important because :
- they Allow humans to write instructions that computers can understand.
- they Enable the creation of software applications like games, word processors, and web browsers.
- they Help in solving mathematical, scientific, and business problems efficiently.
- they Enable automation of tasks, reducing the need for manual work.
- they Help students understand logical thinking and problem-solving skills.
Types of Programming Languages
Programming languages are classified into several types based on how close they are to human language or computer language:
a) Machine Language (Low-Level Language)
- First-generation programming language.
- Consists of binary codes (0s and 1s) that the computer can directly understand.
- Example: 10110010 11001010
- Advantages: Fast and directly understood by the computer.
- Disadvantages: Very difficult for humans to read and write; prone to errors.
b) Assembly Language (Low-Level Language)
- Second-generation language.
- Uses mnemonics (short words or codes) to represent machine instructions.
- Example: MOV A, 5 (Move value 5 into register A)
- Advantages: Easier than machine language; allows more control of hardware.
- Disadvantages: Still complex; needs an assembler to convert to machine code.
c) High-Level Languages
- Closer to human language and easier to write and understand.
- Examples include: Python, Java, C, C++, BASIC, Pascal.
- Advantages: Easier to learn and write; portable across different computers.
- Disadvantages: Must be translated into machine language using a compiler or interpreter.
d) Fourth-Generation Languages (4GL)
- Even closer to human language than high-level languages.
- Used mainly for database management and report generation.
- Example: SQL (Structured Query Language)
Components of a Programming Language
- Keywords: Reserved words with special meaning in the language (e.g., if, for, while).
- Operators: Symbols used for operations like addition (+), subtraction (–), multiplication (*), division (/).
- Variables: Storage locations for data that can change during program execution.
- Constants: Fixed values that do not change during program execution.
- Functions / Procedures: Reusable blocks of code that perform a specific task.
- Syntax: Rules that define the correct way to write a program in that language.
How Programming Languages Work
- A programmer writes code in a programming language.
- The code is translated into machine language using either a compiler or an interpreter.
- Compiler: Converts the whole program into machine code before execution.
- Interpreter: Converts and executes the program line by line.
- The computer executes the machine code, performing the tasks instructed by the program.
Examples of Programming Languages
| Language |
Type |
Use / Application |
| Python |
High-level |
Web development, data analysis, games, AI |
| Java |
High-level |
Mobile apps, desktop software, enterprise apps |
| C |
High-level |
System programming, operating systems, embedded devices |
| C++ |
High-level |
Games, software applications, system software |
| BASIC |
High-level |
Teaching programming to beginners |
| SQL |
Fourth-generation |
Database management |
| Assembly |
Low-level |
Device drivers, embedded systems |
Characteristics of a Good Programming Language
- Easy to Learn and Use: Simple syntax and clear commands.
- Efficient: Produces programs that run fast and use resources wisely.
- Portable: Can run on different types of computers with little modification.
- Reliable: Produces correct results consistently.
- Readable: Easy for humans to understand, maintain, and debug.
Example of programing language Code:
Python Programming Examples
1. Greeting Program
Code:
# This program asks for the user's name and age, then prints a greeting.
name = input("Enter your name: ")
age = input("Enter your age: ")
print("Hello " + name + "! You are " + age + " years old.")
Example Interaction (Final Result):
Enter your name: Ada
Enter your age: 12
Hello Ada! You are 12 years old.
2. Adding Two Numbers
Code:
# This program adds two numbers entered by the user.
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
sum = num1 + num2
print("The sum of", num1, "and", num2, "is", sum)
Example Interaction (Final Result):
Enter the first number: 7
Enter the second number: 5
The sum of 7 and 5 is 12
3. Check Even or Odd Number
Code:
# This program checks if a number entered by the user is even or odd.
num = int(input("Enter a number: "))
if num % 2 == 0:
print(num, "is an even number.")
else:
print(num, "is an odd number.")
Example Interaction (Final Result):
Enter a number: 8
8 is an even number.
Enter a number: 7
7 is an odd number.
4. Multiplication Table
Code:
# This program prints the multiplication table of a number.
num = int(input("Enter a number to see its multiplication table: "))
for i in range(1, 11):
print(num, "x", i, "=", num * i)
Example Interaction (Final Result):
Enter a number to see its multiplication table: 3
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30
Summary
- A programming language is a way to communicate instructions to a computer.
- Languages are classified into machine, assembly, high-level, and fourth-generation languages.
- Programming languages allow humans to create software, solve problems, and automate tasks.
- They include components like keywords, variables, operators, constants, and syntax.
- Examples include Python, Java, C, C++, BASIC, SQL, and Assembly.
Practice / Evaluation Questions
- What is a computer programming language?
- Mention two low-level programming languages and explain the difference between them.
- Give three examples of high-level programming languages.
- Explain the roles of compiler and interpreter in programming.
- What are keywords and operators in programming?
- Why is Python considered easier for beginners than Assembly?
- Give an example of a fourth-generation programming language and its use.
- What are the main characteristics of a good programming language?
- How does a programming language allow humans to communicate with computers?
- Explain why understanding programming languages is important in computer studies.