http://mike-cannon.livejournal.com/ (
mike-cannon.livejournal.com) wrote in
fandomhigh2008-04-15 12:52 am
Entry tags:
Basic Computing Class #14 [Tuesday, Period 3, 4/15]
This week's class was back in the regular classroom. Since it was the last week before finals, Mike stopped in at J,GOB on his way in and brought cupcakes. "Congratulations on making it through the entire semester," said Mike. "Feel free to grab something to eat. You've earned it, and you may need the sugar boost to get through today's lesson."
He looked just a little bit apologetic as he continued. "Today, we're going beyond the basics of just using the computer to look at the programming language that tells the computer what to do. Now, this is probably more than you will ever have to do, and admittedly, it may be just a bit above your comprehension level, so don't worry too much if this seems really complicated. The point is to understand what's going under the hood."
With that, Mike turned around and started writing on the chalkboard.
#include <iostream.h>
main()
{
for(;;)
{
cout << "Hello world! ";
}
}
"This is all the code you need to run a very basic computer program," explained Mike. "The language we're using here is something called C++, which happens to be my very first programming language. In this program, the computer is instructed to print the words 'Hello world!' on the screen. We have a call to a function library, iostream.h, where someone else has helpfully stored the instructions for printing something on the screen. We have main(), which is a special function declaration. Don't worry about what it does. Just remember that every C++ program needs to have that. Then there's the function that starts a recursive loop..."
Mike paused here, considering his words carefully before continuing. "That's really a bit more of an advanced topic. The important part is that you see the instruction cout, which is the command to output something on the screen. The part that is within the quotation marks is what's printed, and then both functions are closed and the program exits. And that's it. What we've just done is trace a program, which means we've looked at how it is interpreted from start to finish. In a more complicated program, we'd be looking for any potential flaws that cause the program to run incorrectly."
"We'll stop there for today, but if you're interested, there are plenty more of examples of the 'Hello world!' program in other languages as well. Good luck with your final exams next week, and if you have any questions for me, I'll be holding extra office hours on Thursday."
He looked just a little bit apologetic as he continued. "Today, we're going beyond the basics of just using the computer to look at the programming language that tells the computer what to do. Now, this is probably more than you will ever have to do, and admittedly, it may be just a bit above your comprehension level, so don't worry too much if this seems really complicated. The point is to understand what's going under the hood."
With that, Mike turned around and started writing on the chalkboard.
#include <iostream.h>
main()
{
for(;;)
{
cout << "Hello world! ";
}
}
"This is all the code you need to run a very basic computer program," explained Mike. "The language we're using here is something called C++, which happens to be my very first programming language. In this program, the computer is instructed to print the words 'Hello world!' on the screen. We have a call to a function library, iostream.h, where someone else has helpfully stored the instructions for printing something on the screen. We have main(), which is a special function declaration. Don't worry about what it does. Just remember that every C++ program needs to have that. Then there's the function that starts a recursive loop..."
Mike paused here, considering his words carefully before continuing. "That's really a bit more of an advanced topic. The important part is that you see the instruction cout, which is the command to output something on the screen. The part that is within the quotation marks is what's printed, and then both functions are closed and the program exits. And that's it. What we've just done is trace a program, which means we've looked at how it is interpreted from start to finish. In a more complicated program, we'd be looking for any potential flaws that cause the program to run incorrectly."
"We'll stop there for today, but if you're interested, there are plenty more of examples of the 'Hello world!' program in other languages as well. Good luck with your final exams next week, and if you have any questions for me, I'll be holding extra office hours on Thursday."
