Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

C++ Beginners Tutorial Part II

Chapter II - Variables, Expressions and Interactivity



Intro:

We'll be going over a few simple things; the cin statement, different expressions and initiating variables. Be sure to read my past tutorial in order to obtain a full understanding of this tutorial which can be found here.
Each chapter will build on the one before.



Let's begin.

An important part to learning the basics of C++ is learning about variables and expressions. Like math, you have variables which can represent almost anything.

Below is an example of using a simple variable and assigning a value to it.

[img]http://i.minus.com/iblrUSqDIAi6ih.png[/img]

As you can see, we can make a variable, assign it a value and have it send the output to the console. Not only, can we assign variables, but we can also do calculations with them as well.

[img]http://i.minus.com/i4pFJKdAQwKqR.png[/img]

Now that we have come this far, we can learn about cin statements.

cin statements - Just as cout is C++'s standard output object, cin is the standard input object. It reads input from the console (or keyboard).

Using cin opens up a ton of new possibilities. Rather than assigning a value manually, we can have the console read values as well.

[img]http://i.minus.com/ibhNbe7kmEQU45.png[/img]


There are a variety of different operators you can learn.

Some arithmetic operators include:

Code
+    addition
-    subtraction
*    multiplication
/    division
%    modulo

Don't feel like reading? Feel free to watch the video below.






In my next tutorial we'll go over different data types, loops and some more uses of everything we've learned so far. If you have any suggestions, please comment below. Also, if you have any questions about anything we've discussed, feel free to PM me. Thanks!



Skype: ryand.8

[Image: XbaG5gl.gif]

wow!
Very useful, I have liked both of these tuts. Keep them coming!
A10 CF is no where near 650 Ti boost 2GB. 650 Ti boost eats A10 and ploughes 7750's angus like no tomorrow

(Jul 1, 2013 07:30 AM)Aesthetics Wrote:  You bought a i3 2220

Girlybitchyvoice: That is so bad ass omg.

*sarcasm*

(Jan 15, 2012 04:50 PM)BigDomePiece Wrote:  wow!
Very useful, I have liked both of these tuts. Keep them coming!

Thanks mate, much appreciated! 🤝
Skype: ryand.8

[Image: XbaG5gl.gif]

Keep it up. So far so good. Are you eventually cover everything? Like pointers/references, etc...?
(Jan 16, 2012 06:42 AM)Mizz Blaise Wrote:  Keep it up. So far so good. Are you eventually cover everything? Like pointers/references, etc...?

I don't know if I'll ever cover EVERYTHING, but yeah I'm going to cover quite a bit. We'll get out of console soon enough and start working on actual programs.
Skype: ryand.8

[Image: XbaG5gl.gif]

(Jan 16, 2012 11:28 AM)ryan⚜ Wrote:  I don't know if I'll ever cover EVERYTHING, but yeah I'm going to cover quite a bit. We'll get out of console soon enough and start working on actual programs.

What do you plan on covering for GUI? DirectX, or what?
Better than my teacher in school!

+rep for this and keep them coming!
thank you for this tutorial mate, was able to create a simple euro to dollar conversion tool without ANY programming experience. you've kept it easy to learn, unlike some other tutorials i tried. really looking forward to what you write next. any chance on sharing when can we expect the next steps?
(Jan 16, 2012 01:49 PM)rhwarrior Wrote:  thank you for this tutorial mate, was able to create a simple euro to dollar conversion tool without ANY programming experience. you've kept it easy to learn, unlike some other tutorials i tried. really looking forward to what you write next. any chance on sharing when can we expect the next steps?

I'm glad I could help you out! Umm, I'm planning on releasing the next one by Friday at the latest. It'll be mostly over loops.
Skype: ryand.8

[Image: XbaG5gl.gif]

Wow amazing tutorial, I easily remembered everything within both except I keep forgetting what #namespace, iostream does but I remember they go on the top :)
These tutorials are amazing and recommend them to anyone who is even curious about learning to code C++
Where is part 3!?!?!?!
He said the next one would come out by friday.. =[
A10 CF is no where near 650 Ti boost 2GB. 650 Ti boost eats A10 and ploughes 7750's angus like no tomorrow

(Jul 1, 2013 07:30 AM)Aesthetics Wrote:  You bought a i3 2220

Girlybitchyvoice: That is so bad ass omg.

*sarcasm*

Nice tutorial man. These will certainly be helpful for those beginning C++.
These are amazing! Thank you for all the help you are giving to us in these tutorials.
Or... you could read a book written by PROFESSIONALS.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by w3w3w3Aug 3, 2021 12:38 PM 1 328 Aug 3, 2021 12:38 PM
Last Post: SIM-5058597
[C] by g4143Aug 21, 2019 01:44 PM 6 511 Aug 21, 2019 01:44 PM
Last Post: YouthInAsia
[.NET] by blake.haleApr 8, 2018 10:31 AM 8 639 Apr 8, 2018 10:31 AM
Last Post: adenfr