5 Basic Elements Of Programming

An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Coming up next: Programming Logic & Syntax: The Programming Toolbox

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
Your next lesson will play in 10 seconds
  • 1:22 Input
  • 2:51 Arithmetic
  • 3:38 Output
  • 4:34 Looping
  • 5:52 Conditional
  • 8:10 Lesson Summary
Add to Add to Add to

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Login or Sign up


Recommended Lessons and Courses for You

Lesson Transcript
Instructor: Lee Webber

Lee holds a master's degree in Information Systems Management. He has taught college-level computer classes.

There are five basic programming elements, or operations: input, output, arithmetic, conditional, and looping. Every program uses at least two of these. This lesson will describe each one to you and show you examples in simple code.

Five Basic Programming Elements

Programming is somewhat like working with building blocks. Given enough children's toy blocks (and enough time and ingenuity), you can build just about anything with only a few kinds of blocks. The five basic elements in programming are:

  1. input: getting data and commands into the computer
  2. output: getting your results out of the computer
  3. arithmetic: performing mathematical calculations on your data
  4. conditional: testing to see if a condition is true or false
  5. looping: cycling through a set of instructions until some condition is met

Let's look at an ATM. You walk or drive up to it, swipe your ATM card, tell it how much money you want, and, after chugging for a moment or two, it spits out cash and a receipt. In this simple example, we have input, arithmetic, and output. Below is a simple flowchart for getting $40 in 'Fast Cash' from a teller machine. We'll follow it through this lesson to show how the five operations can be mapped.

Programming elements flow chart
ATM Arithmetic Flow Chart


Examples of input devices
Input Device Examples

Input can come from just about anywhere: a keyboard, a touchscreen, a text file, and another program are just a few examples. Input is one of the two elements that are used by every program because every program needs some data to work with. When you use an ATM, the input comes from two things: your ATM card and the information you enter on the keypad. Your ATM card has some customer identification on the magnetic strip on the back. It tells the ATM who you are so it can get your account information. But before it will do that, you have to 'authenticate' yourself. The bank wants to make sure it isn't someone who's not you trying to access your account. You authenticate yourself by entering your PIN, which is (or should be) known only to you. Once the bank is happy that it's you, it will ask you what you want to do. In this case, you just want $40, so you select 'Fast Cash,' which will take the money out of your checking. And, the input part of your transaction is over. In a flowchart, input leads to the first process. In this example, it is arithmetic.


Computers can perform all kinds of mathematical operations and functions, from the simple addition or subtraction needed to update your checking account balance after a withdrawal or deposit, to the complex calculus needed to put a satellite into orbit. Not every program needs to do calculations on the data that's entered, but it may still need to do some in order to control what is happening inside the program itself. We'll see that in a minute. In our example, the ATM will check your balance and, if you have enough money, subtract $40 from it. And, that's the arithmetic part - the subtraction. So, this part of our flowchart is a process showing subtraction.


Output is the result that your program gives you. That is the whole purpose of writing a program: to ask a question and get the answer! Output can take many forms - text or graphics, either printed or on a screen, a sound - just about any form that can be interpreted and understood by a human being or another program. In the case of our teller machine, the output is one of the most widely understood things in human society: cash. Back to our example, the machine dispenses the $40 and prints a receipt. The receipt shows you how much you withdrew and what your new balance is. And, that's the output. So, our flowchart goes from the subtraction to the output process, then our program ends.

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 160 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create An Account