This is my first C++ tutorial. In this tutorial, I will be teaching the very basics of C++: In other words, I will be teaching input and output.
Welcome to my first C++ tutorial!
This tutorial will teach you the very basics of programming in C++.
So, what are the very basics of C++? In this tutorial, you will learn input and output.
Input is when you give information to the computer. An example is when you move your computer mouse. If you move it to the left, you are telling the computer to move the clicker on the screen to the left.
Output is when the computer gives information to you. The computer is always outputting information to you. Examples are text, pictures, videos, or music. You get the point…
NOW WE START PROGRAMMING!
Input:
- First download DevCpp (http://www.bloodshed.net/dev/devcpp.html).
- It should look like this:

- Now go to: File/New/Source File.
- Write this in the text area:

- Go to: Execute/Compile and Run.
- Save the file wherever you want.
- Wait a while until the program compiles
- You should get something like this:

At first sight, the code looks very intimidating, but it’s not complicated. If we take off all the comments, it looks like this:

That isn’t that bad… Right? But what does it mean?
The first two lines are libraries. A library is already-made code that makes it easier for us to program. Using libraries lets us program with very little code. If we didn’t use libraries, it would take 50 more times of code to program.
The fifth line is where the main code goes. Just imagine it like this:

The seventh line prints out “hello world” onto the screen. This code uses the first library (
) and would not work without it.
The eighth line waits for any key to be pressed and the program doesn’t do anything until a key is pressed. This code uses the second library (
) and would not work without it.
The ninth line ends the program.
So, now that you learned output, it’s time to learn input.
Output:
- Replace the first program with:

- Go to: Execute/Compile.
- Wait a while until the program compiles.
- It should look something like this:

Since you already know what most of the program does, I will just explain the new parts added.
The seventh line declares a variable “number”. This variable is declared as an integer and it can be used to store any integer value like 3, 1024, 4, -56, -93, or -1000.
The ninth line waits for you to type in any integer and waits for you to press enter. Whatever integer you type will be stored into the variable “number”.
The tenth line types in the value of “number” and then continues on by saying “is also my favorite number”. The value of “number”, as I said before, will be whatever you typed as your favorite number.
So let’s assume that you said your favorite number was 15. The program would say “15 is also my favorite number!”
That is the end of this tutorial. I hope you learned a lot about input and output. Try messing around with the code and see what you get.
Pop Quiz!
Write a program that does the following:













Leave Your Response