I'll "introduce" you to C++ programmer language and programming with it.
And if you notice any grammar&spelling mistakes (there'll be probably a lot of those:P)..I LIVE IN SLOVENIA!...hope that explains a lot:P
Programming never was an easy task.It requires a lot of logical thinking and good imagination to figure how things will work out in your algorythm.
If you want to program you need required tool for that.The tool i would recommend you is called DEV C++ (
http://www.bloodshed.net/).You cant use other programming tools such as:Borland C++, Microsoft Visual C++...
How to learn C++?The best way to learn C++ is to write programs.We're going to learn the basic funtions in C++.We will create mathematical programs and programs that will draw things with selected charachter.Dont expect to learn the art of haxXxing and creating games yet.It's a long path thowards it.
DEV C++
DEV C++ is a good tool beacuse it has included a Compiler and it's for free;)
To create new source file click File > New > Source File.
To compile and run your program click Execute > Compile and Run.
You need to save your project before you can compile and run it.
CREATING FIRST PROGRAM
First program should explain the basics of I/O ( I/O = Input/Output ).
#include <iostream.h>
int main()
{
cout << "HELL-o world"<< endl; //this program is gonna print out the sentence in the " ".
// system("pause");
return 0;
}
If you wish to add comment to your code use the //
Compile and Run the program, and it will prin out : HELL-o world
If your program windows dissappears right after you Compile and Run it, you need to add system("pause"); to your source code(chech the upper code where it should be), this addes the system pause
.
Ok now we know how to Print something on your screen using Output.
Now we're gonna write a short program that will ask user to enter a desired number, and program will print that number out.We will be using both I/O functions here.
#include <iostream.h>
int main()
{
int number; //we need to declare the value with we will input, we will name it number beacuse we'll input a number
cout <<"Enter the desired number: "<< endl;
cin >> number; //here we input the number using keyboard
cout << "The number you choose is: "<< number << endl;
system("pause");
return 0;
}The program will print out: Enter the desired number: (program will wait for user to input a number or any other charachter) enter for example number 6.
The number you chose is:6.
This is the basic I/O system in C++, play arround for a while and it's easy to learn and offcourse one of the basic C++ knowledge.
OPERATORS AND THEIR MEANINGS
Operator Meaning
+ addition
- Substraction
* Multiplication
/ Division
These are 4 basic Operators.
example
(gonna create a program that will ask user for two numbers (number1&number2) and will multiplay these numbers and print out the final resolt)
#include <iostream.h>
int main()
{
int number1, number2, final;
cout <<"input the first number: "<< endl;
cin >> number1;
cout <<"input the second number: "<<endl;
cin >> number2;
final=number1*number2; //here we multiply the first number with the second one, we use the declared final to be the result
cout <<"the result is: "<< final << endl;
system("pause");
return 0;
}
The program will ask user to input 2 numbers: we will enter for example 6 and 5
and on the end the program will print: The result is:30
for exercise create a simple calculator that will do all four basic operator functions.(if you followed trought this "tutorial" it shouldn't be a problem)
This is all for now, there will be more added this weekend.
Feel free too comment and to ask questions...
The path (of C++) has just begun...
lolz xD