November 23, 2017

University at Buffalo Computer Science Class of 2017

For those who have none to very little knowledge of what code is or does, I have prepared a small demo for you (written in C++) to see below. Due to security restrictions, you can’t actually run the program, but I’ll show you what I am doing.

Do not worry, it absolutely  looks complicated and hard, so don’t feel overwhelmed.

 

 

Here is some code for you to look at. To the left is the code and to the right are my comments. Comments are indicated by // and serve no actual functionality in the program. They just indicate to you and other programmers what you are doing with the code.

When I comment //Needed to run the program,  all I mean is that each of these lines of code are necessary to start the program. They are found in 99% of C++ programs. You basically just memorize them and regurgitate them, so don’t worry about what they mean.

 

Here I have added the first line that actually does something. cout << is a command that makes the program write Welcome to Ben’s blog  to a console. A console is just a little text window we use to get feedback from a program. In this case, we just wrote “Welcome to Ben’s blog” to the console. Here is the output:

 

 

Are you lost yet? That’s okay, it’s a lot of information to process at once. One of the hardest things I ever learned was not HOW to program, but how to START programming!!

Here is another example:

And the output:

Untitled

So basically, I expect you to understand:

1. cout << “Welcome to Ben’s blog”;  writes Welcome to Ben’s blog  to a console.

2. int i  declares that a variable named i is going to take an integer.

3. i = 4 * 5  means that the product of 4 and 5 is assigned to i.

4. cout << i  prints i the console.

 

What I don’t expect you to know:

1. What does #include <iostream>, int main(), {}, do?

2. How did you get that console to pop up and write what your code says?

3. How did you get that code to actually function in general?

4. What is the meaning of life?

 

I will not answer the latter questions 1-3 because this is just a basic demo and you don’t need to know these things to learn about what I do. If you have any questions about 1-3 or an answer to 4, feel free to leave a comment below.

Also, if you want to see bit more complex program, click on the second page.

Leave a Reply

Your email address will not be published. Required fields are marked *