ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Programacion En CODEWARRIOR U

Yezman113 de Junio de 2013

22.872 Palabras (92 Páginas)237 Visitas

Página 1 de 92

Learn Programming with C

Page 1

Welcome to the "Learn Programming with C" course from Freescale CodeWarriorU. This course consists

of a collection of lessons that will introduce you to the fundamentals of programming using the C

programming language

Lesson 1: Start at the Beginning 2

Lesson 2: Algorithms and Flowcharts 7

Lesson 3: Variables and Data Types 14

Lesson 4: More Data Types 21

Lesson 5: Computer Arithmetic 29

Lesson 6: Handling Complex Data 35

Lesson 7: Modularity 43

Lesson 8: Conditionals and Branching 48

Lesson 9: Going Loopy 55

Lesson 10: Real World Problems 61

Lesson 11: Coding Up A Storm 64

Lesson 12: Debugging Technique 69

For additional courses, please visit the Embedded Learning Center on the Freescale Semiconductor

website.

Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.

© Freescale Semiconductor, Inc. 2005

Learn Programming with C

Page 2

Lesson 1: Start at the Beginning

Lesson Description: A famous actress and singer noted that the beginning is a "very

good place to start." Thus began the tune "Do Re Mi." So, let's start at the beginning

by finding out why you're here and what your goals are.

Why Do You Want to Learn Programming?

Why do you want to learn programming? This question should be with you throughout

this course. Essentially, there are two kinds of programmers. Those who do it for the pure

love of programming, and those who do it as part of their job.

For the Love of Code

The first kind of programmer writes software for the sheer love and enjoyment of coding.

These people are the true "hackers" of the world -- not those who break into systems,

who are really "crackers."

Programmers in this category often write small programs to help others with a specific

problem that they need to solve. These same programmers will often share ideas and even

source code with others. Freeware and shareware authors generally fall into this category.

Working Programmers

Working programmers are those who program as part of their daily job. They may be

contractors who write software to fulfill a specific need for a company, or they could be

developers at a well-known (or maybe not so well-known) software development

company.

Of course, just because programming is part of the job does not mean the programmer

doesn't love or enjoy programming. However, these programmers have specific tasks in

mind, which are often driven by hard deadlines, structure, and goals.

Which Are You?

Now we come back to my first question, "Why do you want to learn programming?" As

you are only beginning to learn programming and have no experience, you probably don't

fall into either category yet. However, that's not to say that you won't love programming

at some point in the future. Chances are that you are seeking direction, trying to find out

if you will like programming, or if you should seek another career choice. Programming

is not always an easy task. It's sometimes full of frustration, upsets, and stress. But it is

also full of joy, rewards, and a sense of pride from accomplishment. So you must give it a

solid effort before you make your decision.

This course is very basic. I would encourage you to take at least one or two more

programming courses (increasing in skill and knowledge) after this one. I believe that

only then will you have the necessary experience and mindset to make a proper decision.

Learn Programming with C

Page 3

I personally fall into both categories. I program as part of my job, but I also love

programming and try to do as much of it as I can in my spare time.

A Brief History of Programming

You've heard the phrase "necessity is the mother of invention." The idea is no different in

programming. Strictly speaking, programs are developed out of necessity to solve a

problem or to fill a need.

People have always had a desire to solve problems faster. For example, the abacus was

developed in ancient China to perform mathematical calculations more quickly and

easily. The abacus is a visual tool. The user eventually developed a skill not only for

adding quickly but also for pattern matching, i.e., seeing a seven without counting the

beads. Pattern matching is an extremely important skill in some high-level programming

languages, particularly object-oriented languages such as C++ and Java.

Over time, the need to quickly solve increasingly complex equations became critical in

the rapidly expanding fields of physics, chemistry, and engineering. But the flash point

came during World War II in British efforts to design machines that could quickly break

German codes. These machines had to perform in hours repetitive tasks that would take

weeks for a group of people to complete. They were also enormous and broke down

frequently. Fully electronic computers eventually evolved from these humble origins. So

we've come from a "computer that can fit into a single room" to a computer that can

perform a billion calculations per second and fits comfortably on your lap.

This high-velocity advancement requires programmers to continually create new

instructions for the computer to follow. Remember, computers are incredibly fast but

completely stupid. They only do the tasks you tell them to do. No more, no less.

Problem-Solving for Everyone

Computer programming is based on solving problems, such as "How can I draw a line

from point A to point B?" or "How do I write an MP3 player?"

Let's take a practical example to illustrate further. Inventory has to be the most mundane

task in any company. However, accurate inventory is vital to successful sales. Someone

has to make sure that there is enough product in inventory to sell, order more if there isn't

enough, and record all that information somewhere.

Problem: Repetition x Time

Taking inventory used to mean someone had to go around and physically count every

item in stock. This task alone could often take several days, depending on the size of the

business, the number and type of products being sold, and where those items were

located. And this had to be done on a daily, weekly, or monthly basis. Here you see the

repetition involved and the amount of time it took.

Learn Programming with C

Page 4

Next, the inventory would have to be reconciled with what had been sold to make sure

everything matched up. This process could involve a little accounting practice as well,

maintaining accounts payable and accounts receivable and matching them to inventory.

Finally, analysis of that data would determine how much product to purchase.

Solution: Computer and Software

In today's world, this whole process is virtually eliminated and replaced by a combination

of computer hardware and software known as a Point of Sale (POS) system and takes

seconds instead of days. The computer keeps track of how much inventory you have, how

much you sold, and how much money you made (or didn't make). Additionally, some

POS systems include features such as warning you when inventory is low and ordering

more at that time electronically, showing you monthly averages of product moved so you

can better gauge your business growth, and more. The possibilities really are endless.

Identity

The example above shows one situation and the accompanying solution. However, the

entire computer industry is based around the principle and practice of problem solving.

Solving problems requires that you first identify the problem (too much time and

manpower for inventory). Once you've found the problem, you need to analyze the

problem to find out where things can be simplified or automated. Finally, you write code

to solve the problem.

Problem solving is a repetitive process that we'll discuss further in the next session.

Seven Steps of Computer Programming

Programming is a process that can be broken down into the following seven steps:

1. Define or refine the problem

2. Design the program

3. Write the code

4. Compile the code

5. Test and debug

6. Document

7. Modify and maintain

Let's take a closer look at each step.

Define the Problem

You've seen one example of this already. Defining the problem is called the problem

domain. This step is often the easiest of the seven but that doesn't mean you can approach

it haphazardly. This step determines the direction of what follows.

Learn Programming with C

Page 5

Defining the problem is essential to fully understanding the problem. The initial

description of a problem is usually vague. You need to refine the problem so that it

becomes precise. Programmers often work with users (the people

...

Descargar como (para miembros actualizados) txt (121 Kb)
Leer 91 páginas más »
Disponible sólo en Clubensayos.com