12/23/2002 Entry: ""
Posted by Maynard @ 03:44 PM MST


The 4 Fundamentals of Computer Programming
With a new semester starting after the new year, it might be good to help out those poor students who have to suffer through the rigors and trials of a semester of an introductory programming class. To that end, I've summarized all the code you will write this next semester into four areas: decisions, loops, data structures, and functions. Click on.
These are the only four things you will write in code. Everything you do will be a combination of these four things.
Decisions are made with if-then-else statements, which check the value of a boolean statement. In the C language family (C, C++, C#, and Java) you also have a switch-case statement, which executes code based on an integer value.
Loops are also done with boolean conditions and integer checking. You use a for loop to repeat a task a certain number of times (the integer way of looping) and a while loop to perform a task when a boolean condition is true.
In every language you have basic variable types that store different types of data. These data types can be grouped to make more complex data types. This is called creating a new data structure. In object-oriented languages this is called a class or object. In function-based languages they are called structures.
Functions are also called subroutines and enclose a body of code that can be referred to by another body of code. Functions can be given one or more variables and can return a variable. You can also manipulate the variables you are given. Activating a function is the same as calling it. The variables you send it are sometimes called parameters and what it sends back is called the return value.
Object-Oriented Programming, a term you will almost certainly encounter in your class, is just the combination of data structures and functions to create more complex data structures. It also gives you the ability to simplify and compartmentalize your data structures. You can easily understand OOP if you think of it as putting your data structures into a family tree.
Hopefully that will clear things up at least a little for you.

Replies:
(1)

how do you write a program using computer programming to tell a person whether or not the number they entered is a prime number using while looping???
Posted by stephanie moore @ 03/31/2003 02:01 PM MST

Add A New Comment