Intro To C++/Playing with '''''operator'''''

From testwiki
Revision as of 20:14, 22 May 2019 by imported>Texvc2LaTeXBot (Replacing deprecated latex syntax mw:Extension:Math/Roadmap)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Navigate

Basic Math

C++ can be used to do basic math. The operators used in the basic math are listed in the table below.

Operator Operation
Arithmetic Operator + addition
Substraction
+ Multiplication
Division
% Modulus
++ Increment
Decrement
Assignment Operator = "a=b" is equivalent to "a=b"
+= "a+=b" is equivalent to "a=a+b"
= "a=b" is equivalent to "a=ab"
*= "a+=b" is equivalent to "a=a*b"
/= "a/=b" is equivalent to "a=a/b"
%= "a%=b" is equivalent to "a=a%b"
Comparison Operator == Equality
!= Inequality
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
Logical Operator && Logical AND
|| Logical OR
! Logical NOT

Basic math operators in C++ have some distinguishing features:

  • Bulleted list item
  • Bulleted list item
  • Bulleted list item

Part of Basic math operation is demonstrated in the C++ program below:

Checking Size

The memory size of any variable can be discovered using the C++ sizeof operation.The sizeof operator syntax is look like this:

sizeof(var)

The sizeof operator is demonstrated in the program as follows:

Casting Data Types

Any data-types except "string" could be converted to another data type through "casting". Casting syntax in C++ looks like this:

variable-name=static-cast <data-type> variable-name

Casting with C++ form is demonstrated in the program as follows:

Further reading