Programacion En CODEWARRIOR U
Enviado por Yezman11 • 3 de Junio de 2013 • 22.872 Palabras (92 Páginas) • 211 Visitas
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
...