0% found this document useful (0 votes)
8 views12 pages

Programming Language

A programming language is a formal set of instructions used to implement algorithms and communicate with computers, classified into low-level and high-level languages. Low-level languages include machine and assembly languages, while high-level languages encompass procedure-oriented, problem-oriented, object-oriented, and natural languages. Additionally, the document discusses types of errors in programming, algorithms, flowcharts, pseudocode, and program control structures.

Uploaded by

ranjitasah02
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views12 pages

Programming Language

A programming language is a formal set of instructions used to implement algorithms and communicate with computers, classified into low-level and high-level languages. Low-level languages include machine and assembly languages, while high-level languages encompass procedure-oriented, problem-oriented, object-oriented, and natural languages. Additionally, the document discusses types of errors in programming, algorithms, flowcharts, pseudocode, and program control structures.

Uploaded by

ranjitasah02
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Programming Language

A programming language is a formal language comprising a set of instructions that produce


various kinds of output. It is used to implement algorithms and communicate with computers.
Programming languages can be broadly classified into low-level languages and high-level
languages.

Low-Level Languages

Low-level languages are closer to the hardware and consist of instructions that a computer's
processor can execute directly. They are machine-dependent and categorized into two types:
1. Machine Level Language
2. Assembly Level Language

High-Level Languages

High-level languages are closer to human language and are easier to understand and write. They
are machine-independent and include:

1. Procedure-Oriented Language
2. Problem-Oriented Language
3. Object Oriented Language
4. Natural Language

Types of Programming Languages

[Link]-Level Language

 Definition: The language directly understood by a computer's CPU. Instructions are written in
binary (0s and 1s).
 Major Points:
1. Written in binary (e.g., 101010).
2. Fast and efficient execution.
3. Hardware-specific and non-portable.
4. Error-prone and difficult to debug.
5. Used for system-level programming.
 Advantages:
1. Fastest execution as it directly communicates with the hardware.
2. No need for a compiler or interpreter.
 Disadvantages:
1. Extremely difficult to write and debug.
2. Completely machine-dependent (not portable).
 Example: 10110000 01100001 (represents loading a value into a register in x86
architecture).

[Link] Level Language

 Definition: A low-level language that uses mnemonics (symbolic representations) for


machine instructions.
 Major Points:
1. Symbolic representation like MOV, ADD, SUB.
2. Requires an assembler for translation.
3. Easier than machine language but still hardware-specific.
4. Provides direct hardware control.
5. Used in embedded systems and hardware drivers.
 Advantages:
1. Easier to read and write compared to machine language.
2. Allows direct manipulation of hardware.
 Disadvantages:
1. Hardware-specific and non-portable.
2. Requires knowledge of processor architecture.
 Example:

MOV AL, 1; Load 1 into register AL ADD


AL, 2; Add 2 to AL
MOV AX, 5; Load the value 5 into the AX register
MOV BX, AX; Copy the value of AX into BX

[Link]-Oriented Language
 Definition: A high-level language based on procedures (functions or routines) to perform
tasks.
 Major Points:
1. Focuses on procedures and functions.
2. Code is organized into reusable modules.
3. Suitable for general-purpose programming.
4. Requires a compiler or interpreter.
5. Examples include Q-Basic, C, Pascal.
 Advantages:
1. Promotes code reusability.
2. Easier to debug and maintain.
 Disadvantages:
1. Lacks real-world modeling (not object-oriented).
2. Can become complex for very large systems.
 Example:

void add() {
int a = 5, b = 10;
printf("%d", a + b);
}

[Link]-Oriented Language

 Definition: High-level languages designed to solve specific types of problems or


domains.
 Major Points:
1. Focused on specific applications or industries.
2. Examples include SQL (databases), MATLAB (engineering).
3. Abstracts complex computations.
4. Reduces development time for domain-specific tasks.
5. Not as versatile as general-purpose languages.
 Advantages:
1. Highly optimized for specific tasks.
2. Reduces development effort for targeted domains.
 Disadvantages:
1. Limited to specific use cases.
2. Not suitable for general-purpose programming.
 Example:
o SQL:

SELECT * FROM employees WHERE salary > 50000;

[Link] Language

 Definition: A type of high-level programming language that mimics human


languages and is used for Artificial Intelligence (AI).
 Major Points:
1. Used in natural language processing (NLP) tasks.
2. Relies on machine learning and AI for interpretation.
3. Examples include Python (used in NLP libraries).
4. Bridges the gap between human communication and computers.
 Advantages:
1. Easy for humans to understand.
2. Expands possibilities for AI and machine learning applications.
 Disadvantages:
1. Processing natural language is computationally expensive.
2. Ambiguity in human language can lead to misinterpretation.

Errors:

Errors in programming languages occur when the program doesn't behave as


expected. These errors can be broadly categorized into the following types:

[Link] Errors

 Definition: Errors in the structure or grammar of the code that violate the
rules of the programming language.
 Causes:
o Missing semicolons, brackets, or parentheses.
o Misspelled keywords or identifiers.
o Improper use of language constructs.
 Examples:
o C Language:
int main()
{
printf("Hello, World!")
return 0;
}

(Missing semicolon after printf statement.)

[Link] Errors

 Definition: Errors in the logic or design of the program, causing


incorrect output or behavior.
 Causes:
o Incorrect algorithm or faulty implementation.
o Misuse of operators or conditions.
 Errors in calculations.

 Her penis lost.


o Mother slap
o Examples:
 C
Language
int main()
{
int a = 5, b = 10; if
(a > b) {
printf("A is greater\n");

return 0;

}
[Link] Errors

 Definition: Errors that occur during the execution of the program, often
causing it to crash or behave unpredictably.
 Causes:
o Division by zero.
o Accessing invalid memory locations.
o File handling errors (e.g., file not found).
o Infinite
loops. Examples:
 C
Language
int main()
{
int a = 5, b = 0;

printf("%d", a / b); // Division by zero return


0;

[Link]

An algorithm is a step-by-step procedure or formula for solving a problem. It


defines a sequence of unambiguous instructions that lead to the desired result.
Algorithms are often expressed in natural language, pseudocode, or
programming languages.

Characteristics of a Good Algorithm

 Input: Takes zero or more inputs.


 Output: Produces at least one output.
 Definiteness: Each step is clear and unambiguous.
 Effectiveness: Achieves the desired output with finite resources and
time.
 Finiteness: Executes in a finite number of steps.
 Generality: Solves a class of problems, not just a single instance.
[Link]
A flowchart is a graphical representation of an algorithm. It uses symbols to show
the sequence of steps and the flow of control in a process. Flowcharts are
especially useful for visualizing the process, making it easier to understand and
debug.

Symbols Used in Flowcharts

 Oval (Start/Terminate): Represents the start or end of a process.


 Rectangle (Process): Represents a process or instruction.
 Diamond (Decision): Represents a decision point (e.g., yes/no).
 Parallelogram (Input/Output): Represents input or output operations.
 Arrow: Represents the flow of control.
 Connectors: To connect the symbols in large no. of sheets.

1. Algorithm to Find the Sum of Two Numbers

Algorithm (Sequence)

1. Start.
2. Input two numbers: a and b.
3. Calculate the sum: sum = a + b.
4. Display the sum.
5. Stop.

2. Algorithm to check if a Number is Even or Odd

Algorithm (selection)

1. Start.
2. Input a number n.
3. If n % 2 == 0, display "Even".
4. Else, display "Odd".
5. Stop.
Pseudocode

Pseudocode is a high-level description of a program's logic that uses plain language and programming
constructs

Example:

START

PRINT "Step 1"

PRINT "Step 2"

PRINT "Step 3" END

EXAMPLE:

START

INPUT number

IF number > 0 THEN

PRINT "Positive number"

ELSE

PRINT "Negative or Zero"

END
PROGRAM CONTROL STRUCTURES

Program control structures in programming are fundamental constructs that allow you to control the flow of
execution of instructions within a program. They are divided into three main categories:

1. Sequential Control Structure

 Description: The default mode of execution where statements are executed one after the other, in
the order in which they are written.

2. Selection Control Structure

 Description: Enables decision-making in a program. The flow of control depends on the


evaluation of conditions.
 Types:
o if Statement
o if-else Statement
o Nested if
o if-else if Ladder
o Switch Case

3. Repetition (Looping) Control Structure

 Description: Allows a block of code to be executed multiple times based on a condition.


 Types:
o while Loop
o do-while Loop
o for Loop

You might also like