Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/feed-rss2.php on line 8
‘#if’ Articles at TC101 Fall 2015 https://kenscourses.com/tc101fall2015 Introduction to Programming Python and C++ Thu, 29 Oct 2015 03:14:51 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Use of IF and ELSE in C++ https://kenscourses.com/tc101fall2015/2015/use-of-if-and-else-in-c/ Thu, 29 Oct 2015 03:14:51 +0000 http://myfreakingcrazythoughts.wordpress.com/?p=152 Continue Reading →]]> IF.

As you might know, an if statement is the one that allows the user to control if a program enters a section of code or not based on whether a given condition is true or false. One of the important functions of the if statement is that it allows the program to select an action based upon the user’s input.

Without a conditional statement such as the if statement, programs would run almost the exact same way every time. If statements allow the flow of the program to be changed, and so they allow algorithms and more interesting code.

When using an If statement it is important to know that the possible return will always be true or false, according to the parameters that the user gave to the program. This parameters will be declared with operators which are the ones who check if the condition is true or false.

For example:

>     Greater than              5 > 4 is TRUE

<     Less than                 4 < 5 is TRUE

>=    greater than or equal     4 >= 4 is TRUE

<=    less than or equal        3 <= 4 is TRUE

==    Equal to                  5 == 5 is TRUE

!=    not equal to              5! = 4 is TRUE

When a condition is true the result will be 1 and when the condition result to be negative the return will be 0.

 

Basic structure of an IF statement.

If (TRUE) {

Execute the next statement}

 

As you can see, the structure is pretty clear. Inside the parenthesis there are the conditions and outside there are the actions that the program will do if the statement is true.

ELSE.

This statement works when we want to give an alternative response when our IF condition results to be false. So this statement basically says what we want to do if our first statement isn’t true.

An ELSE structure will look like this:

If (TRUE) {

  // execute these statements if TRUE

}

Else {

  // execute these statements if FALSE

}

ELSE IF.

But what happen if we want to declare two or more conditions of IF? That is the situation when we use ELSE IF. When we use an “else if” statement following an if statement and its body; that way, if the first statement is true, the “else if” will be ignored, but if the if statement is false, it will then check the condition for the else if statement. If the if statement was true the else statement will not be checked. It is possible to use numerous else if statements to ensure that only one block of code is executed.

For example:

If (<condition>) {

// execute these statements if <condition> is TRUE

}

Else if (<another condition>) {

// execute these statements if <another condition> is TRUE and

// <condition> is FALSE

}

Thank’s for the support of cprogramming.com, it really helped me a lot!

-The admin.

]]>
https://creativecommons.org/licenses/by/4.0/
Use of the conditional “if” https://kenscourses.com/tc101fall2015/2015/use-of-the-conditional-if/ Wed, 16 Sep 2015 21:31:49 +0000 http://mferprogr.wordpress.com/?p=59 ]]> Today I am going to explain you what “if” is for in c++.

Here’s a video done by myself for you:

And now here’s a simple code example:

#include <iostream>
using namespace std;
int hours;
int main()
{
cout<<“How many hours of study do you need to approve?”;
cin>>hours;
if (hours>5)
cout<<“You should start now”<<endl;
return 0;
}

]]>
https://creativecommons.org/licenses/by/4.0/
Masteries 15 and 16 – If and Else https://kenscourses.com/tc101fall2015/2015/masteries-15-and-16-if-and-else/ Tue, 15 Sep 2015 13:47:00 +0000 http://kenscourses.com/tc101fall2015/?guid=c8caf67d866f4f589488ba336684aa0b Here I will show you that I know how to use IF and ELSE stamentes.

This is the basic form, I put it simple to understand the syntax quickly. Here are some works that I made using IF and ELSEs.

If you want to know more check my WSQs.

]]>
https://creativecommons.org/licenses/by/4.0/