Lecture-2 - Intro To Programing
Lecture-2 - Intro To Programing
Recommended Books:
Text Book / Essential Reading: Introduction to computers, Peter Norton, 4th Edition A book on C by Kelly Reference Books / Literature: Computer Today, Donald H Sanders, 3rd Edition Computers, H.L Capron 6th Edition Let us C by Yashvant Kanethar Turbo c/c++ programming by Robert Lafore
Introduction to Computer Programming- CSC141 Muhammad Usman Yaseen [email protected]
Computer programming
Humans are intelligent and computers are dumb.
Humans can think on their own, computers cant. Humans know what to do, computers dont.
Very simply, telling the computer what to Introduction to Computer Muhammad Usman Yaseen do is called computer programming! Programming- CSC141 [email protected]
Computer program
A computer needs instructions to perform a task.
It just cant decide on its own not at all! The instructions have to be
Detailed Step by step Exact Accurate Complete
Muhammad Usman Yaseen [email protected]
computer program
The set of step by step instructions following which, a computer can perform the required task, is known as a computer program.
These instructions
Are written by a human being, called a computer programmer to
Control the computer. Make use of the computers tremendous power to get the job done.
I/O
Recall that
Every task to be done, problem to be solved requires some input. The input need to be processed in a certain manner. The processing generates some kind of results that solve the problem.
I/O
It all starts with the output.
Getting the output is the objective. Feeding the input is a requirement. Processing the input to get to the output is what needs to be done.
This is where you solve the problem!
Some examples
Problem: a glass full of orange juice is needed. Input: a couple of oranges. Processing:
1. Cut the oranges 2. Squeeze the oranges 3. Catch the juice flowing out of the oranges into a glass.
Output: a glass full of orange juice drink Introduction to Computer Muhammad Usman Yaseen [email protected] it! CSC141
some examples
Problem: shirt needs to be pressed. Input: a wrinkled shirt. Processing:
1. Heat the iron. 2. Adjust the shirt on a flat surface. 3. Press the shirt with the hot iron until the wrinkles go away.
Computers I/O
Computers also rely on input, processing and output. You need to get something done from the computer, you need the output. The computer needs relevant input to get to the output. It gets the input, processes it, and generates the output.
Introduction to Computer Programming- CSC141 Muhammad Usman Yaseen [email protected]
computers I/O
Computer
Computer program
You want the computer to do something, you want the output. You have the required input to get the output from. You need the computer to process the input and give the output, but
The computer doesnt know what to do remember?
Introduction to Computer Programming- CSC141 Muhammad Usman Yaseen [email protected]
computer program
So you need to tell the computer how to process the input to get the output. You will tell it through detailed step by step instructions. Step by step instructions are a computer program.
computer program
So you instruct the computer, step by step, telling it what to do, how to do to produce the output you need through the input you feed! Thus, a computer program instructs the computer to
Accept the input through input devices. Process the input and generate the output. Give the output back through output devices.
Introduction to Computer Programming- CSC141 Muhammad Usman Yaseen [email protected]
computer program
Everything that happens inside a computer is under its processors control. To make the computer do something, you need to instruct the processor. So a computer program instructs the computers processor to perform the task. A computer program has instructions written in it, which a computer can understand. Introduction to Computer Muhammad Usman Yaseen Programming- CSC141 [email protected] Computer program = computer software.
computer program
Everything that a computer does is governed by a computer program. There are different programs/software that make the computer perform different activities. Examples of programs
Microsoft windows Microsoft word Adobe Photoshop etc
Programming language
You communicate with humans in a language they understand. You need to communicate with a computer in a language it understands. The language a computer understands is called Machine Language.
Its extremely complicated.
So complicated that its not understandable for humans.
Introduction to Computer Programming- CSC141 Muhammad Usman Yaseen [email protected]
programming language
To communicate with somebody who doesnt understand your language, you need to translate your language into his language. To communicate with a computer, you need to
Write instructions in a language that you understand. Translate those instructions into machine Introduction to Computer Usman Yaseen understands. language that Muhammad the computer
Programming- CSC141 [email protected]
programming language
A language which you use to write computer programs is called programming language.
The language you write programs in has to be one that you can understand.
Programming languages that humans can understand are known as high level languages.
The computer only understands machine language. You need to write programs in high level languages and convert/translate them into Introduction to Computer Muhammad Usman Yaseen machine language. Programming- CSC141 [email protected]
Coding
A computer program you write in a high level language is also referred to as Source Code. Programming is also referred to as Coding. A person who writes computer programs is sometimes referred to as a Coder.
The word Programmer is more appropriate and more common.
Introduction to Computer Programming- CSC141 Muhammad Usman Yaseen [email protected]
Translator
Microsoft Word is a computer program which helps you compose text documents. Microsoft Paint is another program which helps you draw images. Similarly, there are programs you use to translate programs you write in high level languages into corresponding machine language.
Introduction to Computer Programming- CSC141 Muhammad Usman Yaseen [email protected]
translator
A program that translates the entire source code into its machine language equivalent in one go is called a Compiler.
Compiler is said to compile the source code.
A program that translates the source code into its machine language instruction by instruction is called an Interpreter.
Interpreter translates one instruction at a time.
Introduction to Computer Programming- CSC141 Muhammad Usman Yaseen [email protected]