introduction to computer programming

18
Introduction to Computer Programming Lanie P. Plecerda Instructor I

Upload: nsu-biliran-campus

Post on 24-Dec-2014

124 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Introduction to computer programming

Introduction to Computer

Programming

Lanie P. PlecerdaInstructor I

Page 2: Introduction to computer programming

Computer program - is a list of instructions that the computer machine follows to properly accept input, correctly process them and present the results in the most understandable way.

Computer Programming – is considered to be an art and at the same time a science. It is an art because there is no standard way to interpret a problem and solve it using a standard form of programming procedures and styles. It is fast becoming a science because standard programming practice is starting to be adopted.

Page 3: Introduction to computer programming

Programs fall into two major classes: application programs and operating systems. An application program is one that carries out some function directly for a user, such as word processing or game-playing. An operating system is a program that manages the computer and the various resources and devices connected to it, such as RAM (random access memory), hard drives, monitors, keyboards, printers, and modems, so that they may be used by other programs.

Page 4: Introduction to computer programming

A programmer uses another type of program called a text editor to write the new program in a special notation called a programming language. With the text editor, the programmer creates a text file, which is an ordered list of instructions, also called the program source file. The individual instructions that make up the program source file are called source code. At this point, a special applications program translates the source code into machine language, or object code — a format that the operating system will recognize as a proper program and be able to execute.

Page 5: Introduction to computer programming

Three types of applications programs translate from source code to object code: compilers, interpreters, and assemblers. The three operate differently and on different types of programming languages, but they serve the same purpose of translating from a programming language into machine language. A compiler translates text files written in a high-level programming language—such as Fortran, C, or Pascal—from the source code to the object code all at once

Page 6: Introduction to computer programming

Computer is composed of:

1. CPU (Central Processing Unit) – this is where all mathematical and logical forms of processing are done on data.

2. Memory – before a computer can do any productive work such as programming, it has to remember things such as data it needs to produce information.

Page 7: Introduction to computer programming

3. Input and Output Device – data have to come into the computer by first entering them through input devices. Ex. Keyboard. After the computer executes a program to process data and produce information, this information remains in the memory. Part of the program has to show these results to the outside world. Output devices such as monitor screen and printers are used to display the results to the user.

Page 8: Introduction to computer programming

4. Software – computers today come bundled with some software already installed in them.

Operating System – performs for the programmer many tasks that used to be very difficult to program

Page 9: Introduction to computer programming

Two forms of Memory• Internal memory (RAM-Random

Access Memory) – stores programs and data that are executed and processed by the computer.

• Secondary memory – supplements RAM so those computers are able to permanently save programs and data that are not yet needed for execution and processing. Ex. Floppy disk, hard disk & etc.

Page 10: Introduction to computer programming

The following are standard Operating System functions.

•Validating user identification every time the user uses the computer

•Provides standard functions like editor, compilers and linkers

•Manages files of the user by providing functions like Copy, Delete, Append

Page 11: Introduction to computer programming

The following are standard Operating System functions.

• Retrieves data out of data files• Manages memory for the user by

determining where in the memory a program is to be loaded every time it is called to run

• Makes communication between the CPU, Memory and input/output devices transparent to the user or the user are unaware of these things while they are at work.

Page 12: Introduction to computer programming

High level languages – are programming languages

that are closer to human language than to machine language. They are characterized to use common English words as their instructions. Aside from that, high level languages have the following characteristics:

Page 13: Introduction to computer programming

High level languages • Requires additional step of compilation

or translation so that from high-level, another program that has exactly the same meaning and intended results in low-level or machine language can be generated and loaded into the computer and executed.

• A compiled program is usually not as efficient as when the program was originally written in machine language or assembly. This is due to the fact that compilers add a lot of extra overheads in terms of memory and non-optimized logical translations.

Page 14: Introduction to computer programming

Each of these programming languages was designed to solve particular kinds of problems.

• COBOL – Common Business Oriented Language was designed to solve business problems like accounting.

• FORTRAN – Formula Translation is a high level language used for scientific and engineering applications.

• Pascal and C – are general-purpose language. They are high-level language but they can be embedded with assembly language code effectively making these languages middle-level languages. C language is responsible in the implementation f major software including operating systems, compilers and software development tools.

Page 15: Introduction to computer programming

The Simplest computer programs perform three basic operations:• get the input from the keyboard• process the input data• display the results on the screen

INPUT DATA

PROCESS DATA

DISPLAY ALL RESULTS

Page 16: Introduction to computer programming

The most basic form of a C program follows a very simple format:

pre-processor directives

main function{declarationsstatements}

Page 17: Introduction to computer programming

First Example/*Converts weight in pounds to kilograms*/#include <stdio.h>#define kg_in_pound .454

int main(){float pounds, kilograms; /*declare both weights as float data

type*/printf(“Enter weight in pounds :”)

scanf(“%f”,&pounds);

kilograms = kg_in_pound * pounds;

printf(“5.2f Pounds is equal %.2f kilograms,\n”, pounds, kilograms);

getch();return(0);}

Page 18: Introduction to computer programming

- END -