Thursday, March 8, 2012

Goals of this Blog

So for those of you who are reading this, I hope its not that bad! I am trying to solidify concepts in programming for me. Majority of the things I will discuss are very basic. I am primarily programming in C++ and Java. Java being the emphasis at this point in time. So for my first post I'm going to discuss if statements.

The most important thing about if statements is that it takes in a boolean value in it. The general format of an if statement is as follows

if(somethingIsTrue()){
then do the following.
}
else{

}

Now an important part of a boolean is that in C++ a true value is anything that is not zero. So if you do

if(1){
then do something
}
else{
quit
}

Then it would proceed to do something. This is very useful for when you return a null value(ZERO!) or an actual value(Say 10000, or something like the word cow). This allows us to use it a little bit more dynamically.

Another thing is the formatting. There are a few different formats for doing an if statement. The generally accepted ways you should format are as follows;

if(somethingIsTrue)
{
then do something
}


OR

if(somethingIsTrue){
then do something
}
To sum it up.


An if statement allows us to control whether we do something or not. Which is a lot of trouble.

if(somethingIsTrue()){
then do whats in the brackets.
}

Thank you for reading! Please leave comments in the bottom. I intend to use this blog to help me learn!

No comments:

Post a Comment