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
‘#conditional’ Articles at TC101 Fall 2015 https://kenscourses.com/tc101fall2015 Introduction to Programming Python and C++ Wed, 16 Sep 2015 23:13:20 +0000 en hourly 1 https://creativecommons.org/licenses/by/4.0/ Use of ”else” with a conditional https://kenscourses.com/tc101fall2015/2015/use-of-else-with-a-conditional/ Wed, 16 Sep 2015 23:13:20 +0000 http://mferprogr.wordpress.com/?p=63 ]]> by Lynn Jacobs
by Lynn Jacobs

My last post was about the use of ”if” as a condition in c++. Now I should complement that post with an explanation about ”else”.

When we use ”if”, we declare a condition. Then we make our program do something under that condition. But, what happens if the condition is not accomplished? Well, if we don’t use else, the program would end there. But, if we use else, we can make our program do some other thing when the condition we declared is not accomplished.

Here’s a code as an 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”;
else
cout<<“You have some free time!”
return 0;
}

And now, to clarify a little bit more what “else” works for I made a short poem:

by RasMarley

If else

If you do this,

I’ll do that.

If you say this,

I’ll say that.

If you take this,

I’ll take that.

We unconditionally

will state conditions,

not just in reality,

but in coding too.

What if?

Constantly questioning,

our head is

stuck in a single string.

We should open ourselves

to a second way,

where it’s not just about if’s

but also about else.

Else makes all clearer,

else makes all brighter.

”if”conditions are great, yes,

but complement them with else,

that’s even greater.

“If you don’t teach me,

you’ll see me failing.

Else, if you do,

you’ll see me nail it.”

]]>
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/