0% found this document useful (0 votes)
155 views8 pages

Mis 101 Ho-1

The document provides an introduction to computer programming. It discusses what a computer program is versus computer programming. It also discusses bugs that can occur when a programmer does not correctly instruct the computer. The document then gives a brief history of computer programming languages, from machine languages to high-level languages. It categorizes programming languages as procedural, object-oriented, functional, declarative, and special languages. Finally, it outlines the typical program development cycle of analyzing a problem, designing a solution, coding, testing and debugging, and documenting the program.

Uploaded by

abrarbaig
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
155 views8 pages

Mis 101 Ho-1

The document provides an introduction to computer programming. It discusses what a computer program is versus computer programming. It also discusses bugs that can occur when a programmer does not correctly instruct the computer. The document then gives a brief history of computer programming languages, from machine languages to high-level languages. It categorizes programming languages as procedural, object-oriented, functional, declarative, and special languages. Finally, it outlines the typical program development cycle of analyzing a problem, designing a solution, coding, testing and debugging, and documenting the program.

Uploaded by

abrarbaig
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Kingdom of Saudi Arabia Royal Commission at Yanbu University College Yanbu Department of CS Yanbu Al-Sinaiyah

1 Semester 2008-09
st

MIS-101 HO-1
INTRODUCTION TO PROGRAMMING USING VISUAL BASIC.NET

1
1.1

INTRODUCTION TO COMPUTER PROGRAMMING


Computer Program vs. Computer Programming

A computer is an electronic, automatic and programmable device that accepts input, processes the input and gives output, which can be stored for future retrieval. A computer, by itself, knows absolutely nothing. It doesnt even know how to display information on a screen or access a hard drive for data. It doesnt know how to access the internet nor does it know how to play a sound. But computers are very good at following and repeating instructions flawlessly and very quickly. This is what makes these machines so powerful. Someone had to write the instructions, called code or program, to make the computer do what we want it to do. The objective of this handout is to help the students be familiar with how to write their own programs in order to make the computer perform the tasks they want. Program: is a set of instructions that tells the computer what to do. Programming: is the act of writing code or program that is interpreted by the computer to carry out some repeatable task. 1.2 Bugs Computers always do exactly what they are told to do. However, programmers dont always instruct the computer correctly. When this occurs, it is referred to as a bug. A bug can have varying degrees of severity. Some bugs can cause the computer to become unresponsive and others are mere annoyances. There are many reasons why bugs are introduced into software. They include the following: 1. laziness on the part of the programmer 2. a misunderstanding of a particular feature of a programming language 3. not enough time to test every feature thoroughly. A bug is a mistake in a program introduced by a programmer, which may lead to undesired results.

_____________________________________________________________________________________________ Prepared By: Abubakar Adam Page 1 of 8 October 26, 2011

A BRIEF HISTORY OF COMPUTER PROGRAMMING

2.1 Evolution of Programming Languages To write a program for a computer, you must use a computer language. A computer language is a set of predefined words that are combined into a program according to predefined rules (syntax). Over the years, computer languages have evolved from machine language to natural languages. A time line for computer languages is presented in Figure 1.

Figure 1: Evolution of computer languages

2.1.1. Machine Language In the early days of computers, the only programming languages available were machine languages. Each computer has its own machine language, which is made of streams of 0s and 1s. The instructions in machine language must be in streams of 0s and 1s because the internal circuit of a computer is made of switches, transistors, and other electronic devices that can be in one of two states: off or on. The off state is represented b 0; the on state is represented by 1. The only language understood by a computer is machine language. 2.1.2. Symbolic Language In the early 1950s, Grace Hopper developed the concept of a language that simply mirrored the machine languages using symbols, or mnemonics, to represent the various machine language instructions. Because they used symbols, these languages were known as symbolic languages. A special program called an assembler is used to translate symbolic code into machine language. Because symbolic languages had to be assembled into machine language, they soon became known as assembly languages. 2.1.3. High-Level Language High-level languages are portable to many different computers, allowing the programmer to concentrate on the application rather than the intricacies of the computers.

Updated By: Mirza Abrar Baig

Page 2 of 8

MIS101-HO1

Over the years, various languages, most notably BASIC, COBOL, Pascal, Ada, C, C++, and Java, were developed. 2.1.4. Natural Languages Ideally, you could use your natural language (e.g., Arabic, English, or French), and the computer would understand it and execute your requests immediately. Although this may sound like something out of science fiction, considerable work on natural languages is being done in labs today. So far, its use in industry is still quite limited. 2.1.5. Turning a Program in a High-Level Language into Machine Language It is the job of the programmer to write the program and then to turn it into an executable (machine language) file. There are three steps in this process: 1. Writing and editing the program 2. Compiling the program 3. Linking the program with the required library modules. See Figure 2.

Program Editor

Compiler

Preprocessor Translator

00101110000101 10101000011110 ... 01010101111010 01110000011010 Linker

Object Module (this is the code in machine language)

001011100001010010101001 101010000111101111100111 ... 010101011110100010100011

Figure 2: Building a program

Compilation: the process of converting a program written in HLL or Assembly Language into machine language. 2.2 Categories of Programming Languages Today, computer languages are categorized according to the approach they use in solving a problem and the category of problems they solve. As shown in Figure 3, computer languages can be categorized into five categories:
Updated By: Mirza Abrar Baig Page 3 of 8 MIS101-HO1

} #include <iostream.h> int main (void) { int a; ...... . . . ......


Source file Executable file

1. 2. 3. 4. 5.

Procedural (Imperative) Languages Object-Oriented Languages Functional Languages Declarative Languages Special Languages
Computer Languages

Procedural

Object-Oriented

Functional

Declarative

Special

Figure 3: Categories of computer languages

2.2.1. Procedural Language Procedural Language is a set of instructions that are executed one by one from beginning to end unless an instruction forces the control elsewhere. Even in this case, the program is still a series of instructions that are executed one after another, although some may be executed more than once or some may be skipped. Examples of procedural programming languages include: FORTRAN (FORmula TRANslation), COBOL (COmmon Business-Oriented Language), Pascal, C etc. 2.2.2. Object-Oriented Language (OO) OO programming is a mindset or a philosophy that attempts to: 1. simplify application development 2. relates code objects to real world objects 3. creates more flexible applications Examples of OO programming languages include: C++, Java, VB.NET 2.2.2.1. Classes vs. Objects The basic building block of Object-Oriented programming is the class; class is closely related to object. A class is a description of a group of objects with common properties (attributes), behavior (operations), relationships, and semantics. An object, on the other hand, is an instance of a class. Informally, an object represents an entity, either physical, conceptual, or software. An object is something that has: 1. State 2. Behavior 3. Identity

Updated By: Mirza Abrar Baig

Page 4 of 8

MIS101-HO1

The state of an object is one of the possible conditions in which an object may exist. The state of an object normally changes over time. Behavior determines how an object acts and reacts to requests from other objects. Behavior is represented by the set of messages it can respond to (the operations the object can perform). Assigns, teaches, takes etc. Each object has a unique identity, even if its state is identical to that of another object

2.2.3. Functional Language In functional programming, a program is considered a mathematical function. In this context, a function is a black box that maps a list of inputs to a list of outputs. See the following Figure 4.

n inputs

Function (Black box)


Figure 4: Function in a functional language

m inputs

For example, summation can be considered a function with n inputs and only one output. The function takes the n inputs, adds them, and creates the sum. A functional language does the following: 1. It predefines a set of primitive (atomic) functions that can be used by any programmer. 2. It allows the programmer to combined primitive functions to create new functions LISP (LISt Programming) is an example of functional programming languages. 2.2.4. Declarative Language Declarative Language uses the principle of logical reasoning to answer queries. It is based on formal logic defined by Greek mathematicians and later developed into what is called first-order predicate calculus. Logical reasoning is based on deduction. Some statements (facts) are given that are assumed to be true; the logician uses solid rules of logical reasoning to deduce new statements (facts). For example, the famous rule of deduction in logic is If (A is B) and (B is C), then (A is C) Using this rule, we have If Ehab is a human and a human is mortal Then Ehab is mortal. Prolog is an example of declarative language.

Updated By: Mirza Abrar Baig

Page 5 of 8

MIS101-HO1

2.2.5. Special Language During the last decade, some new languages have emerged that cannot be placed in the four categories just discussed. Some are a mixture of two or more models and others belong to a specific task. Examples include HTML, PERL, and SQL.

PROGRAM DEVELOPMENT CYCLE

Since Software refers to a collection of instructions for the computer, the computer only knows how to do what the programmer tells it to do. Therefore, the programmer has to know how to solve problems. The following are steps that will help the programmer plan his program development. i) ii) iii) iv) v) vi) Analyze: Define the problem. Design: Plan the solution to the problem. Choose the interface: Select the objects (text boxes, buttons, etc.). Code: Translate the algorithm into a programming language. Test and debug: Locate and remove any errors in the program. Complete the documentation: Organize all the material that describes the program.

PROGRAMMING TOOLS

Three tools can be used to convert algorithms into computer programs: Flowcharts - Graphically depict the logical steps to carry out a task and show how the steps relate to each other. Pseudo code - Uses English-like phrases with some VB.NET terms to outline the program. A step by step series of instructions for solving a problem (a recipe is an example of an algorithm). Additional symbols are shown in the following table. Symbol Name Terminator Flow line Data(Input/Output) Process Meaning Used to represent the start or end of a task Used to connect symbols and indicate the flow of logic Used for input and output operations Used for arithmetic and data-manipulation operations. Used for any logic or comparison operations. This symbol has one entry and two exits. The path chosen depends on whether the answer to a question is yes or no.
Page 6 of 8 MIS101-HO1

Decision

Updated By: Mirza Abrar Baig

Magnetic Disk

A database

Connector

A jump from one point to another

Document

A document or report

Predefined Process

A formally defined sub-process

4.1 Examples Example1: The following example shows a decision flowchart.

Updated By: Mirza Abrar Baig

Page 7 of 8

MIS101-HO1

Example 2: The following example shows a looping flowchart.

REFERENCE

[1] Behrouz A. Forouzan, Foundation of Computer Science, THOMSON, BROOKS/COLE, Pacific Grove, CA 93950, USA, 2003. [2] Evangelos Petroutsos, Mastering Visual Basic .NET, SYBEX Inc., USA, 2002. [3] Internet

Updated By: Mirza Abrar Baig

Page 8 of 8

MIS101-HO1

You might also like