Programming Language Geek

May 19, 2008

Conditions : True or False

Filed under: General Programming

Probably all programming languages depend on conditions. A condition is the most basic feature programming possesses. It allows programs to behave in a dynamic manner. These are like pathways being split up everytime decisions have to be made. Basically, conditions return only values either True or False. Below is an example of a condition:

45 equals 29. X

Of course, in mathematics, this is not true. Since 45 is a number with a different value than 29. Therefore, the above condition returns False, while below returns True.

A equals A. True.

In a Boolean logic (programming), True and False have corresponding values. Always remember, that True has a mathematical value of 1, while False has a value of 0. If you come to think of it, 1 and 0 are the accepted values of a computer, much more popularly known as Binary numbers. Now don’t disregard this very useful fact, since you might be handling complicated conditions in the future, and you may be able to take advantage of this information.

Now how are these conditions being used in programming?

Later you will be able to meet certain programming statements such as "If, Else, ElseIf", or "Do While, Loop", or "Select Case, or switch". These statements always follow conditions. Without conditions, you can’t put them to work. A simple explanation about how they can be used is as follows:

Perhaps you are to attend on a scheduled meeting. There are some things to consider especially those which depend on certain occurrences. You have prepared different sets of plans, which you designed specifically for a certain event. Suppose you have Plan A and Plan B. That, if there will only be at most 10 people to show up in the meeting, you will execute Plan A, but, if there will more than 10 people to attend the meeting, then you will proceed immediately to Plan B. Now there’s already the condition. Of course, with the set condition, if and only if that there are at most 10 people to show up, you will definitely execute Plan A, if not, then you go for Plan B.

In programming, these conditions are being put to code using Conditional Operators. Here’s a list of common conditional operators:

= / ==
Is equal to
>
Is greater than
<
Is less than
>=
Is equal or greater than
<=
Is equal or less than

There is also a conditional operator which negates any condition as listed above. This is the operator "Not", having a symbol in C / C++ as "!" or an Exclamation Point. Negation is by means of converting the condition into its opposite value. If True is being negated, then it becomes False, while it does the otherwise.

So, if you put the condtions given as example at the early part of this article into code, it should look like this:

45 = 49 (for Visual Basic) or 45 == 49 (for C / C++), returning False
A = A or A == A, returning True

If you have questions or perhaps clarifications, please leave ‘em all here. 

May 17, 2008

What is a Programming Language?

Filed under: General Programming

As the term suggests, simply, programming language is just a language used for communication. We use English as our means of communication. This is actually a medium we use so that we can set a common understanding to other people. For us to be able to express ourselves in a proper manner, we use language. And at the same, we are being understood by those who also knew about language.

Now a programming language is what you will use to communicate to a computer, especially compilers (I might be able to tackle more about compilers later on). Since it is the only language a computer understands, for us to communicate to computers, we must learn this language. By doing so, we may be able to command the computer whatever we needed them to perform.

As of today, there are already a wide variety of programming languages. One of my favorite language is Visual Basic. There are also other languages such as C or C++, Java, and many more. These languages differ in syntax (or dialects plus accent). Of course, if you’re a Chinese, you won’t be able to communicate with a Japanese if you haven’t learned their language. It’s because the structure of their languages differ. It’s just the same with programming languages. How you write a Visual Basic code is different when writing a C++ code. But one thing’s for sure. No matter what language you use, can always come up to an application which may be able to perform lots of features and functions.

These applications (in the form of executables *.exe) are what we call as Programs. Remember these: Programmers, who are skilled in the field of computers, use a Programming Language. Now through the abilities of Programming Languages with the help of required corresponding compilers, they produce a final output which is a Program. The process of creating a program is what we call as Programming, or writing of source codes. If you have questions about these terms, just leave ‘em all here.

Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com