Select Page

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

#include

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

expressionequivalent 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

operatordescription
==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

operatorshort-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

operatorasm equivalentdescription
&ANDBitwise AND
|ORBitwise inclusive OR
^XORBitwise exclusive OR
~NOTUnary complement (bit inversion)
<<SHLShift bits left
>>SHRShift bits right

Precedence of operators

LevelPrecedence groupOperatorDescriptionGrouping
1Scope::scope qualifierLeft-to-right
2Postfix (unary)++ --postfix increment / decrementLeft-to-right
()functional forms
[]subscript
. ->member access
3Prefix (unary)++ --prefix increment / decrementRight-to-left
~ !bitwise NOT / logical NOT
+ -unary prefix
& *reference / dereference
new deleteallocation / deallocation
sizeofparameter pack
(type)C-style type-casting
4Pointer-to-member.* ->*access pointerLeft-to-right
5Arithmetic: scaling* / %multiply, divide, moduloLeft-to-right
6Arithmetic: addition+ -addition, subtractionLeft-to-right
7Bitwise shift<< >>shift left, shift rightLeft-to-right
8Relational< > <= >=comparison operatorsLeft-to-right
9Equality== !=equality / inequalityLeft-to-right
10And&bitwise ANDLeft-to-right
11Exclusive or^bitwise XORLeft-to-right
12Inclusive or|bitwise ORLeft-to-right
13Conjunction&&logical ANDLeft-to-right
14Disjunction||logical ORLeft-to-right
15Assignment-level expressions= *= /= %= += -=
>>= <<= &= ^= |=
assignment / compound assignmentRight-to-left
?:conditional operator
16Sequencing,comma separatorLeft-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 😉