• No results found

Lecture1.pdf

N/A
N/A
Protected

Academic year: 2020

Share "Lecture1.pdf"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

1

Introduction to Computer Programming

& Problem Solving

2

¾Computer: Computer is a smart or intelligent

machine which can work only on certain instructions given by a human being.

(2)

3

¾ Computer Language: It is a set of rules and conventions used to convey information to computer.

i. Machine Language: Native language of computer. It is in binary string of 0 and 1.

ii. Low-Level Language: Machine language is still used by the computer as it processes data. Low level language translates specified operation symbols into machine language equivalent. E.g. Assembly language.

iii. High level Language: It is a programming language where an instruction resembles an

4

everyday language. Instructions are given to computer by using convenient letters, symbols and text rather than 1 and 0’s. E.g. Pascal, BASIC, C Language.

Differences b/w high, low and machine language:

¾ Main difference is that high level is much easier and understandable by human being.

¾ Secondly in high level one instruction is equivalent to several machine level instructions.

(3)

5 Compiler:

¾ Converts all of the source code into machine code, creating an executable file, called object code.

¾ Once compiled, program is a stand-alone executable file that no longer needs the compiler to run.

¾ Each programming language requires its own compiler to translate particular nuance of that language.

For E.g:

C requires a C Compiler while Pascal required Pascal Compiler.

6 Interpreter:

¾ Also converts source code to machine code, but instead of creating an executable object code file, it simply executes each bit of machine code as it is converted.

¾ Because they translate code on a fly, they have a certain flexibility that compiler lacks.

¾ Because, code must be interpreted each time it is run, interpreted code however runs slower than compiled code, and a copy of interpreter must accompany code everywhere it goes. So every system that needs the program must have a copy of interpreter as well as the source code.

For E.g:

(4)

7

¾Source Program: Original high level written program.

¾Object Program: Machine level translated program.

8 Processing of a High level Program:

¾ Use an editor or a word processor program to enter each line of source program into memory and to save it on disk as a source file.

¾ Use a compiler program to translate source program into machine language. If there are syntax errors i.e. errors in grammar then compiler displays these on monitor. Use editor program to correct the errors by editing and resaving source program.

(5)

9 Processing of a High level Program:

¾ Linker program combines object program with additional object files, that may be needed by the program to execute and save the final machine level program as executable file on the disk.

¾ Loader program places executable file in memory , ready to execution.

10 Steps to prepare a Program:

¾ Following steps must be taken to prepare/write a program:

1. Problem: Actual objective or task; must be well –defined.

2. Analysis: Type of information provided; problem to be solved; Type of machine used. Language to be used; Which software and hardware to use.

3. Algorithm: All programming steps are written in human language step by step to solve the problem.

(6)

11

4. Flowchart:Graphical, pictorial or

diagrammatical representation of logic or the algorithm.

5. Coding: Flowchart transferred to any computer language step by step.

6. Integration: To integrate different modules at one place.

7. Debugging (overall testing): Find out and remove errors from the program.

8. Documentation & Installation: User guide/manual to help user and complete installation of software.

12

Types of Errors:

There are 4 types of errors that may be encountered:

1. Syntax errors:

The statement that doesn't follow the rule of programming language causes syntax error.

Caused by typing, spelling, or other kind of similar mistake.

2. Run-time errors:

Appears by programmer’s carelessness and are not severe enough to prevent the translator from translating the program.

(7)

13

3. Logical errors:

Most difficult to detect. Can be avoided by careful planning and by following a properly constructed flow chart.

If a program runs but doesn't produce the desired results, then there may be an error in logical organization of program.

4. Operator errors:

Normally occurs while entering input data by the operator.

14 Flow chart Symbols:

Flow chart uses boxes of different shapes to represent different types of instructions.

These symbols have been standardized by the ANSI (American National Standard Institute) Some of the major symbols are:

1. Terminator:

Beginning and ending of program. First and last step of flowchart.

2. Input / Output:

(8)

15 3. Process:

Represent arithmetic operations (+,-,*,/) and data movement instructions.

Mathematical instruction / formulas are also represented in it.

4. Decision:

Represent occurrence of a question or takes the decision.

5. Documentation:

Indicate o/p on printer or any other documentation process.

16 6. On-page connector:

Connects flow on same page.

If program is too long and it might cause some confusion connect the program to make it simple.

Letter/digit placed in circle to indicate link.

7. Off-page connector:

When program is too long to fit on a single page, use this to continue on other page.

8. Flow lines with arrow heads:

(9)

17 Example: Draw a flow chart to find the largest of 2 numbers A and B.

START

Read A,B

IS A>B

PRINT A PRINT B

END

18 Exercise: Draw a flow chart to find the sum of first 50 numbers.

END START

IS N=50

PRINT Sum Sum = 0

N = 0

N = N+1

References

Related documents

In general, to determine fuel moisture effect on the gasification process, the model calculated such parameters as: amount of produced syngas, heating value of the syngas, cold gas

Thus, from the style of its architecture and decoration, Ribāṭ-i Māhī is closely related to Ribāṭ-i Šaraf, and in turn, both caravanserais show a very close similarity in

0900-0950 Room utilized by LE/CI Track during this session Room utilized by LE/CI Track during this session Room utilized by DIB Track during this session Room utilized

Marbles (guardians of Cyberspace), Hacker (the villain, out to destroy the Motherboard and gain control over Cyberspace), Buzz and Delete (Hacker’s henchmen). CUE

Adaptation Process O’CoPE Ontology Indexing Process Reification Process Tacit Knowledge (TK) EK Indexed Semantically Annotated EK + Reuse Intentions Member Profile Static Information

Although the pressure field in the piping system is not free of resonance effects associated with the piping acoustics, the effect of different pipe ends on the

In this paper, we analyze the expected Information captured Per unit of Energy consumption (IPE) as a function of the event type (in terms of the utility function), the event

Online discussion forums provide students the chance to engage in asynchronous dialogue and allows students to interact with, and learn from, each others' experiences (Carr