Visual Basic Matt
Apprentice
First you'll need a compiler. I personally use Dev-C++ because it seems to work fine.
Download Dev-C++.
Select your language, hmm...
Finish Installation.
Select your theme, I personally think this to be pretty neat.
Wait as it configures/parses all the files.
Be patient as it loads up for the first time.
You always will get these neat little tips, I suggest you read them as they are a great help on getting to understand the program.
Now it is officially installed and ready to use.
First to start out you need to open a new source file.
You can do this by going to file/New/Source File, or by simply pressing Ctl+N.
You will see a blank screen where your code will go.
Starting out you must remember one thing, in all of your programs you must put the following inclusion at the top of all your code, which is where you will be including other functions aswell.
Your screen should look like this.
When you include something like that, for instance, lets say you wanted the program to use mathematical methods without having to create your own. You can import cmath, which would look like this.
You would just have to add that to the top of your code and this would make it very easier to do things without creating your own functions. This is just one of the many functions you can include to your project. Although you Must always include the iostream in all of your projects.
Next you will start off with the main function of your program. This will be triggered the second the user opens the application.
That is the main function that should always be the first line of code in your program after all of the includes and your variable declaration. Your code will lie in between the brackets "{" and "}".
Inside the brackets you should start out with the following code.
This will allow the program to communicate with the user.
First off, you will need to declare your variable.
This will tell C++ that x is your integer. You can now make the variable "x", any value you wish.
There is two main communications with C++ and the user. They would be "Cin" and "Cout". You may ask. What does that mean? Well, The "C" stands for console because we are making a console application. In is to ask the user for a variable of some sort. Out is to output the info to the user. So lets say we wanted to ask the user what their favorite number was. We would use the "Cout" command to ask the user the question.
So now the user knows that he/she needs to input here favorite number, but the application must be able to read what he/she inputs. That is why we have the "Cin" command.
You will notice that there is a ";" after all of the lines of code here, well this is what tells C++ that it is done at that line of code, and doesn't need to be continued. But be careful, during if commands and many other commands you may do, the line isn't finished doing its job yet, therefore it needs to continue on until its done.
Well, now we told the program to read what the user put in, but what will we do with that number? Well, we can do a million things with a number, but just for now, lets have the program tell the user the number. We will do this with the "Cout" command to display it to the user.
You should notice how their is "<" and ">" well, simply there opposite so when you do "Cin" and "Cout they will be opposites. Another thing is that anything in the """ will be recognized as text given to the user and without them, the program will know to go figure out what the variable "x" is, or whatever the variable is. One last thing you will see is "endl" That simply ends the line so the next piece of code will not be upon it.
If you were to compile and run it, it would disapear really fast after the user inputs his/her favorite color. This is because we need to tell C++ to pause the program at its current line. You would just add this bit of code.
Then finally you will need to have the program stop itself, or just finialize everything, just add the following to the bottom of your function.
Your code should finally look something like this.
Now that your done test it out by going to Execute/Compile and run or simply press F9.
It should end up looking like this.
This was my first programming tut, I hope you enjoyed it. Please comment/rate and I'll try and make more. I know I'm visual basic matt but I don't just program in vb.
Thanks!
Download Dev-C++.
Select your language, hmm...
Finish Installation.
Select your theme, I personally think this to be pretty neat.
Wait as it configures/parses all the files.
Be patient as it loads up for the first time.
You always will get these neat little tips, I suggest you read them as they are a great help on getting to understand the program.
Now it is officially installed and ready to use.
First to start out you need to open a new source file.
You can do this by going to file/New/Source File, or by simply pressing Ctl+N.
You will see a blank screen where your code will go.
Starting out you must remember one thing, in all of your programs you must put the following inclusion at the top of all your code, which is where you will be including other functions aswell.
Code:
#include <iostream>
When you include something like that, for instance, lets say you wanted the program to use mathematical methods without having to create your own. You can import cmath, which would look like this.
Code:
#include <cmath>
Next you will start off with the main function of your program. This will be triggered the second the user opens the application.
Code:
int main()
{
}
Inside the brackets you should start out with the following code.
Code:
using namespace std;
First off, you will need to declare your variable.
Code:
int x;
There is two main communications with C++ and the user. They would be "Cin" and "Cout". You may ask. What does that mean? Well, The "C" stands for console because we are making a console application. In is to ask the user for a variable of some sort. Out is to output the info to the user. So lets say we wanted to ask the user what their favorite number was. We would use the "Cout" command to ask the user the question.
Code:
cout << "What is your favorite number:";
Code:
cin >> x;
Well, now we told the program to read what the user put in, but what will we do with that number? Well, we can do a million things with a number, but just for now, lets have the program tell the user the number. We will do this with the "Cout" command to display it to the user.
Code:
cout << "Your favorite number is " << x << "." << endl;
If you were to compile and run it, it would disapear really fast after the user inputs his/her favorite color. This is because we need to tell C++ to pause the program at its current line. You would just add this bit of code.
Code:
system("pause");
Then finally you will need to have the program stop itself, or just finialize everything, just add the following to the bottom of your function.
Code:
return 0;
Your code should finally look something like this.
Now that your done test it out by going to Execute/Compile and run or simply press F9.
It should end up looking like this.
This was my first programming tut, I hope you enjoyed it. Please comment/rate and I'll try and make more. I know I'm visual basic matt but I don't just program in vb.





