Site hosted by Angelfire.com: Build your free website today!

Computer History

Za3eem Homepage

What is Programming?

How do we write a Program?

What is a Programming Language?

What is a Computer?


What is ASP Active Server Page?

What is Virtual Campus?

 


need any help please e-mail me

 

 

 

Computer

How do we write a Program?

To write a sequence of instructions for a computer to follow, we go through a two phase process: problem solving and implementation.

Problem-Solving Phase 
1. Analysis and specification. Understand (define) the problem and what the solution must do.
2. General solution (algorithm). Develop a logical sequence of steps to be used to solve the problem.
3. Verify. Follow the steps exactly to see if the solution really does solve the problem.

Implementation Phase 
1. Specific solution (program). Translate the algorithm into a programming language (code).
2. Test. Have the computer follow the instructions, and then manually check the results. 
If you find errors, analyze the program and the algorithm to determine their source, and then make corrections. Once a program has been written, it enters a third phase: maintenance.

Maintenance Phase 
1. Use. Use the program.
2. Maintain. Modify the program to meet changing requirements or to correct any errors that show up in using it.

Each time the program is modified, it is necessary to repeat the problem-solving and 
implementation phases for those aspects of the program that change. Together, the 
problem-solving, implementation, and maintenance phases constitute the program's life cycle.A computer is not intelligent. It cannot analyze a problem and come up with a solution. The programmer must analyze the problem, arrive at the solution, and then communicate it to the computer. What's the advantage of using a computer if it can't solve problems? Once we have a solution for a problem and have prepared a version of it for the computer, the computer can repeat the solution quickly, again and again. The computer frees people from tasks that require great speed or consistency, or that are repetitive and boring.
The programmer begins the programming process by analyzing the problem and developing a general solution, called an algorithm. Understanding and analyzing a problem take up much more time than implies. They are the heart of the programming process.
------------------------------------------------------------------------------------
Algorithm A step-by-step procedure for solving a problem in a finite amount of time.
------------------------------------------------------------------------------------

If our definitions of computer program and algorithm look similar, it is because all programs are algorithms, A program is simply an algorithm that has been written for a computer.
An algorithm is a verbal or written description of a logical sequence of actions. We use algorithms every day. Recipes, instructions, and directions are all examples of algorithms that are not programs.
When you start your car, you follow a step-by-step procedure. The algorithm might look something like this:

1. Insert the key.
2. Make sure the transmission is in Park (or Neutral). 3. Depress the gas pedal.
4. Turn the key to the start position.
5. If the engine starts within six seconds, release the key to the ignition position.
6. If the engine doesn't start in six seconds, release the key, wait ten seconds, and repeat 
steps 3 through 6, but not more than five times.
7. If the car doesn't start, call the garage.

Without the phrase "but not more than five times" in step 6, you could be trying to start the car forever. Why? Because if something is wrong with the car, repeating steps 3 through 6 over and over again will not start it. This kind of never-ending situation is called an infinite loop. If we leave the phrase "but not more than five times" out of step 6, the procedure does not fit our definition of an algorithm. An algorithm must terminate in a finite amount of time for all possible conditions.
Suppose a programmer needs an algorithm to determine an employee's weekly wages. The algorithm reflects what would be done by hand: 

1. Look up the employee's pay rate.
2. Determine the number of hours worked during the week.
3. If the number of hours worked is less than or equal to 40, multiply the number of hours by the pay rate to calculate regular wages.
4. If the number of hours worked is greater than 40, multiply 40 by the pay rate to calculate regular wages, and then multiply the difference between the number of hours worked and 40 by \{ times the pay rate to calculate overtime wages. 
5. Add the regular wages to the overtime wages (if any) to determine total wages for the week.

The steps the computer follows are often the same as those you would use to do the calculations by hand. After developing a general solution, the programmer tests the algorithm, "walking through" each step mentally or manually. If the algorithm doesn't work, the programmer repeats the problem-solving process, analyzing the problem again and coming up with another algorithm. 
Often the second algorithm is just a variation of the first. When the programmer is satisfied with the algorithm, he or she translates it into a programming language, a set of rules, symbols, and special words used to construct a program. We use the Pascal programming language in this book.
------------------------------------------------------------------------------------
Programming Language
A set of rules, symbols, and special words used to construct a computer program.
------------------------------------------------------------------------------------
A programming language is a simplified form of English (with math symbols) that adheres to a strict set of grammatical rules. English is far too complicated a language for today's computers to follow. Programming languages, because they limit vocabulary, are much simpler.
Although a programming language is simple in form, it is not always easy to use. Try giving someone directions to the nearest airport using a vocabulary of no more than 36 words, and you begin to see the problem. Programming forces you to write very simple, exact instructions.
Translating an algorithm into a programming language is called coding the algorithm. The product of that translation—the program—is tested by executing (running) it on the computer. If the program fails to produce the wanted results, the programmer must debug it: determine what is wrong and then modify the program or even the algorithm to fix it. The combination of coding and testing an algorithm is called implementation.
There is no single way to implement an algorithm. For example, an algorithm can be translated into more than one programming language. Each translation produces a different implementation. Even when they translate an algorithm into the same programming language, different people are 
likely to come up with different implementations. Why? Because every programming language allows the programmer some flexibility in how an algorithm is translated. Given this flexibility, people adopt their own styles in writing programs, just as they do in writing short stories or essays. Once you have some programming experience, you develop a style of your own. Throughout this book, we offer tips on good programming style.
Some people try to speed up the programming process by going directly from the problem definition to coding the program . A shortcut here is very tempting and at 
first seems to save a lot of time. However, for many reasons that become obvious to you as you read this book, this kind of shortcut actually takes more time and effort. Developing a general solution before you write a program helps you manage the problem, keep your thoughts straight, and avoid mistakes. If you don't take the time at the beginning to think out and polish your algorithm, you'll spend a lot of extra time debugging and revising your program. So think first and code later! The sooner you start coding, the longer it takes to write a program that works.
In addition to solving the problem, implementing the algorithm, and maintaining the program, documentation is an important part of the programming process. Documentation is the written text and comments that make a program easier for others to understand, use, and modify. Most programs are used by many different people over a long period of time. Each of those people must be able to read and understand your code.

-------------------------------------------------------------------------------
Documentation The written text and comments that make a program easier for others to understand, use, and modify.
-------------------------------------------------------------------------------
After you write a program, you must give the computer the information or data necessary to solve the problem. Information is any knowledge that can be communicated, including abstract ideas and concepts. Data is information in a form the computer can use—for example, numbers and 
letters.
------------------------------------------------------------------------------
Information
Any knowledge that can be communicated. 

Data Information that has been put into a form a computer can use.
------------------------------------------------------------------------------


Ada Lovelace


Charles Babbage


George Boole


Blaise Pascal


Admiral Grace Murry Hopper


Niklaus Wirth