Understanding The Basics Of C++

Man C++ is a really cool language. I hated it very much, even failed in it many times in my school exams. But to be honest, it isn’t that bad at all. You’ll love it, i promise. So its “Understanding The Basics Of C++”

As I had previously announced on my facebook page that i would be starting to write on C++ and other scripts, I also thought to make a tutorial section on this.

In this post i would be telling you about the stings and commands used in C++ to do different kind of magic.

Well first of all you have to know what are header files. They are the basic and needed function commands to run your C++ application.

Header File Types


This is needed to run or compile a C++ application, you may enter the further needed header files to this.

<iostream.h> – Input output stream, needed to run a C++ application

<string.h> – Used to input longer commands.

<conio.h> – Used to clear screen

That’s basic and we are only going to use those. And below are some command which we will use to make applications.

  • int – integer
  • char – character
  • float – define numbers with fractional parts
  • cin – standard input
  • cout – standard output
  • clrscr()/getch() – used to clear screen after a program is runned
  • if/else – Used to switch between commands
  • switch/case – Also used to switch between commands but larger amount of codes can be executed
  • do/while/for – Loop command switch statement

I would be doing a second and third part of this post where I would tell you more, we’ll go chapter wise. So the above were just basic commands we would be using to make low and high level apps.

Arithmetic Operates

+ addition
- subtraction
* multiplication
/ division
% modulo

Compound Assignments

expression equivalent to…
y += x; y = y + x;
x -= 5; x = x - 5;
x /= y; x = x / y;
price *= units + 1; price = price * (units+1);

Increment and decrements

++x; x+=1; x=x+1;

Relational and comparison operators

operator description
== Equal to
!= Not equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to

Logical operators

!(5 == 5) // evaluates to false because the expression at its right (5 == 5) is true

!(6 <= 4) // evaluates to true because (6 <= 4) would be false !true // evaluates to false !

false // evaluates to true

operator short-circuit
&& if the left-hand side expression is false, the combined result is false (the right-hand side expression is never evaluated).
|| if the left-hand side expression is true, the combined result is true (the right-hand side expression is never evaluated).


Bitwise operators

operator asm equivalent description
& AND Bitwise AND
| OR Bitwise inclusive OR
^ XOR Bitwise exclusive OR
~ NOT Unary complement (bit inversion)
<< SHL Shift bits left
>> SHR Shift bits right

Precedence of operators

Level Precedence group Operator Description Grouping
1 Scope :: scope qualifier Left-to-right
2 Postfix (unary) ++ -- postfix increment / decrement Left-to-right
() functional forms
[] subscript
. -> member access
3 Prefix (unary) ++ -- prefix increment / decrement Right-to-left
~ ! bitwise NOT / logical NOT
+ - unary prefix
& * reference / dereference
new delete allocation / deallocation
sizeof parameter pack
(type) C-style type-casting
4 Pointer-to-member .* ->* access pointer Left-to-right
5 Arithmetic: scaling * / % multiply, divide, modulo Left-to-right
6 Arithmetic: addition + - addition, subtraction Left-to-right
7 Bitwise shift << >> shift left, shift right Left-to-right
8 Relational < > <= >= comparison operators Left-to-right
9 Equality == != equality / inequality Left-to-right
10 And & bitwise AND Left-to-right
11 Exclusive or ^ bitwise XOR Left-to-right
12 Inclusive or | bitwise OR Left-to-right
13 Conjunction && logical AND Left-to-right
14 Disjunction || logical OR Left-to-right
15 Assignment-level expressions = *= /= %= += -=
>>= <<= &= ^= |=
assignment / compound assignment Right-to-left
?: conditional operator
16 Sequencing , comma separator Left-to-right


So basically that’s it for today’s post. I would be posting 1-2 c+ programs daily for you. All will be copyright free and you can use them in your projects and school assignments.
Share a little bit 😉

Leave a Reply

Your email address will not be published. Required fields are marked *