Zone's C++ Programming Tutorials #1 Cout function

ZoneAye

Known Member
Messages
12
Reaction score
5
Points
118
whats up you lil fart sniffs this is my first C++ tut i have deiced not to do C as people usually use C++ for console dev etc and am guessing thats why you are learning.

In this tutorial i will go over the cout function its sooooo easy. Its used to output stuff to the console like numbers, text etc so before we begin u will need a ide that can compile C++ code i would recommend Visual studio either 2010 if you want to make stuff in xexs or 2015 if you want to make your code look noice. so lets begin below is a very simple C++ program all it does it out put Hello world to to the console

#include <isostream> // from the C++ library

using namespace std; // tells compiler that your program is in C++

same with the define


// this is called the main function every other function u write must be linked to this main one or it will not run i will go over functions later.

// the {} are used to open and close the function and everything between them are called statements

int main()
{
// first thing this line does is outputs "Hello World" then sends anything after it to a new line use endl to make a new line.
cout << "Hello World" << endl;
// this line just waits for the user to enter a key u can also use getchar(); but i like to use system
system("PAUSE");
}

that is my first C++ tut hope you liked it :smile:

if you want try make a program that prints out your name and age on separate lines i will put the answer in the comments tomorrow :smile:
 

ZoneAye

Known Member
Messages
12
Reaction score
5
Points
118
this is the answer
int main()
{
cout << "Name: Zone " << endl << "Age: 17" << endl;
system("PAUSE");
}
 

john_

Known Member
Messages
14
Reaction score
15
Points
118
Basic calculator.

#Include <Iostream>
Using namespace STD;

INT main() }

Int A;
Int B;
Int Sum;

Cout << "Please Enter your First Number \n";
Cin >> A;

Cout << "Please Enter your second number of choice \n";
Cin >> B;


Sum = A + B;

Cout << "Your answer is... \n" << sum << endl;


Return 0;
{




Again this is just a basic calculator but it's something you can write. Also if you wanna do multiplication you wanna replace the + sign where the "sum = a + b;" is with a * don't put a X as it won't work. Division you wanna put a / . You can also use Codeblocks to write code anyways, Hope this is somewhat useful to anyone!
 

iGArabZz

Member
Messages
79
Reaction score
81
Points
18
Basic calculator.

#Include <Iostream>
Using namespace STD;

INT main() }

Int A;
Int B;
Int Sum;

Cout << "Please Enter your First Number \n";
Cin >> A;

Cout << "Please Enter your second number of choice \n";
Cin >> B;


Sum = A + B;

Cout << "Your answer is... \n" << sum << endl;


Return 0;
{




Again this is just a basic calculator but it's something you can write. Also if you wanna do multiplication you wanna replace the + sign where the "sum = a + b;" is with a * don't put a X as it won't work. Division you wanna put a / . You can also use Codeblocks to write code anyways, Hope this is somewhat useful to anyone!

Awesome! Simple tip, use the code tags to help your thread/post look much cleaner! That's one of the best features I love about Xenforo.

For example :
Code:
This looks much better
 

john_

Known Member
Messages
14
Reaction score
15
Points
118
Awesome! Simple tip, use the code tags to help your thread/post look much cleaner! That's one of the best features I love about Xenforo.

For example :
Code:
This looks much better
thx for the tip!
 
Top