[go: up one dir, main page]

0% found this document useful (0 votes)
19 views7 pages

CS201

The document provides an introduction to programming, defining key concepts such as programs, programming languages, and the programming process. It discusses types of programming languages, the differences between compilers and interpreters, and the structure of a program, including algorithms and flowcharts. Additionally, it covers software types, the history of the C language, and basic programming elements like variables and data types.

Uploaded by

zaibtastic
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)
19 views7 pages

CS201

The document provides an introduction to programming, defining key concepts such as programs, programming languages, and the programming process. It discusses types of programming languages, the differences between compilers and interpreters, and the structure of a program, including algorithms and flowcharts. Additionally, it covers software types, the history of the C language, and basic programming elements like variables and data types.

Uploaded by

zaibtastic
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
You are on page 1/ 7

CS302

Lesson 1

Introduction to Programming

🔹 What is a Program?

 A program is a set of instructions that a computer follows to perform a task.

 Written in programming languages like C++, Python, Java, etc.

🔹 What is Programming?

 The process of writing, testing, debugging, and maintaining a program.

 Converts a real-world problem into a computational solution.

🔹 Types of Programming Languages:

1. Machine Language: Binary code, hardware-specific, hard to read/write.

2. Assembly Language: Uses mnemonics; easier than binary but still low-level.

3. High-Level Languages: User-friendly; examples: C, C++, Python.

🔹 Compiler vs Interpreter

 Compiler: Translates the whole program into machine code before execution.

 Interpreter: Translates and executes line-by-line.

🔹 Basic Structure of a Program:

 Input → Processing → Output

 Programs should follow logical flow and be well-documented.

🔹 Algorithm:

 A step-by-step solution to a problem.

 Should be finite, clear, and effective.

🔹 Flowchart:
 Visual representation of an algorithm using symbols (ovals, rectangles, diamonds,
arrows).

 Helps in understanding and planning before coding.

🔹 Errors in Programming:

1. Syntax Errors: Violations of the language's grammar.

2. Logical Errors: Program runs but gives wrong results.

3. Runtime Errors: Errors during execution (e.g., division by zero).

🔹 Characteristics of a Good Program:

 Efficient, readable, reusable, well-structured, minimal errors

CS201 - Lecture 2 Notes: Programming Languages & Translators

🔹 Types of Programming Languages


1. Machine Language

o Binary code (0s and 1s)

o Directly executed by the computer

o Fast but hard to understand and modify

2. Assembly Language

o Uses mnemonic codes (e.g., MOV, ADD)

o Easier than machine language but still hardware-dependent

o Needs an assembler to convert it to machine code

3. High-Level Languages

o Closer to human language

o Portable across machines

o Examples: C, C++, Java, Python

o Needs a translator (compiler or interpreter)

🔹 Language Translators

Type Description

Converts whole program to machine code


Compiler
at once

Interpret
Translates and executes line-by-line
er

Assembl
Converts assembly code to machine code
er

🔁 Key Differences:

 Compiler: Faster execution, but takes time to compile.

 Interpreter: Slower execution, but easier debugging.


🔹 Advantages of High-Level Languages

 Easy to learn and use

 Portable

 Easier to debug and maintain

 Shorter development time

🔹 Disadvantages

 Slower execution than low-level code

 Needs translation (compiler/interpreter)

Exam-Focused Definitions

 Programming Language: A set of rules to write instructions the computer can


understand.

 Assembler: Converts assembly language to machine language.

 Compiler: Converts high-level language to machine code at once.

 Interpreter: Executes high-level instructions line-by-line.

Two types of Softwares

System, Application Softwere\

Application softwares

Assembler, Debugger, Compilers, File mgmt tools, Operating System, Utilities

System Softwere

Computer Hardwere

System Softwere – Controls the computer it communicates with computer hardware


(keyboared, mouse, modem, sound card etc ) Sub catogaries are operating system,
Device drivers, utilities.
Operating system or OS is a program that manages all the other program in a
computer

Defination -- “Operating system is the software re responsible for controlling the


allocation and usage of hardware sources such as memory, central processing unit (CPU)
time, disk space, and peripheral devices. The operating system is the foundation on
which applications, such as word processing and spreadsheet programs, are built.
(Microsoft)”

Device drivers: The device driver software is used to communicate between the
devices and the computer. We have monitor, keyboard and mouse attached to almost all
PC’s; if we look at the properties of these devices we will see that the operating system
has installed special software to control these devices. This piece of software is called
device driver software

Utility Software: Utility software is a program that performs a very specific task,
usually related to managing system resources.

The compilers and interpreters also belong to the System Software category.

Application software A program or group of programs designed for end users.

History of C language

Developed in late 60s and early 70s in bell laboratories

BCPL and B languages were developed already in those days

BCPL developed un 1967 by Martin Richards for writing OS system Soft and compilers

Ken thampson used B language to create early versions of UNIX OS system at bell lab

Both BCPL and B were typeless languages

Dennis Ritchie developed a general purpose language called C language using diff
features of BCPL & B

In starting C known as development language of UNIX OS.

. In 1989 the standard was approved. ANSI cooperated with international Standard
Organization (ISO) to standardize C worldwide.
Lecture 3 ---- How to Program

First C program
Variables
Data Types
Arithmetic Operators
precedence of Operators
Tips

The sign # is also called sharp.

# include
<iostream.h>
main()
{ cout << “virtual university of Pakistan }

We will look at this code line by line and try to understand them.

<iostream.h> This is the name of the library definition file for all Input Output Streams.
main() The name main is special, in that the main is actually the one which is run when
your program is used.
Cout: This is known as out put stream in C and C++.

Variables: Variables are locations in memory for storing data.


The variable names in C may be started with a character or an underscore _.
In C X=X+1 means that add 1 to the value of X----

Assigment operator: In c language = is uses as assignment operator


Assignment operator is a binary operator binary operator has 2 operands variable on left
hand side and expression on right hand side.

There is difference in algebraic maths and C Language in maths X=2 means the value of X
is 2
Where In C X=2 mean X is variable.

- Integer occupies four bytes in memory.


In C storing small whole num called short has two bytes it can store date in range -32768
to 32767.

Long data type have very large whole num when we want big whole num we use long
data type.
Real NUM – C provides two data type to deal with real numbers num num with decimal
pnts 1.32, 2.43---

1 float, 2 double

Floats use 4 bytes to store data


If want to store a large real num Use double
Double x= 322333.33233;

Char data type used for storing alphabets a, b and c


Airthmetic operators = + - * / all are binary operators

Lecture 4

You might also like