In this tutorial we will learn about some important concepts that are used in programming.

- Semicolon
- Comment
- Data Item
- Variable

As in English, every sentence ends with a full stop .

In programming every statement ends with a semicolon ;

Example

`x = 10;`

We use comment in our program and pseudo code to make note and for short description.

Example:

`//this is a single line comment`

```
/*this is
a multiple line
comment*/
```

In programming we deals with data which are of the following types

**Numeric**

Integer – integer values (without decimal) like -44 , 0 , 1 etc.

Real – real numbers (with decimal) like 12.015 etc.

**Character**

anything enclosed within single quote like 'a' in C, C++ etc.

**String**

multiple characters enclosed within double quote like "Hi" in Java, C, C++ etc.

**Boolean**

TRUE and FALSE

TRUE is also represented by 1

FALSE is also represented by 0

To save data we need variables.

Variable storing Integer data item

`score = 65535;`

Variable storing Real data item

`speed = 230.45;`

Variable storing Character data item

`ch = ‘q’;`

Variable storing String data item

`name = “Yusuf Shakeel”;`

Variable storing Boolean data item

`isGameOver = false;`

A value that will not change throughout the execution of the program is called a constant.

Example:

`3.14 value of PI`

`9.8 value of g (acceleration due to gravity)`

It is used to assign value to variables

Example

`x = 7; //This statement assigns 7 to variable x`

We can perform math operation in program.

Addition +

`Example: x = 1 + 2; // result 3`

Subtraction –

`Example: x = 5 – 3; // result 2`

Multiplication *

`Example: x = 4 * 5; // result 20`

Division /

`Example: x = 4 / 2; // result 2`

It is used to increment the value of a variable by 1

Example:

```
count = 5;
count++; //value of count becomes 6
```

Note! The above statement is equivalent to

`count = count + 1;`

It is use to decrement the value of a variable by 1

Example:

```
count = 5;
count--; //value of count becomes 4
```

Note! The above statement is equivalent to

`count = count - 1;`

First use the value then increment.

Example

```
count = 5;
x = count++; //x is assigned the value 5 then count is incremented by 1
Print: x; //output 5
Print: count; //output 6
```

The above code is equivalent to

```
count = 5;
x = count; //first x is assigned the value
count = count+1; //then count is incremented
Print: x;
Print: count;
```

First increment then use the value.

Example

```
count = 5;
x = ++count; //count is incremented by 1 then x is assigned the value 6
Print: x; //output 6
Print: count; //output 6
```

The above code is equivalent to

```
count = 5;
count = count+1; //first count is incremented
x = count; //then x is assigned the value
Print: x;
Print: count;
```

First use the value then decrement.

Example

```
count = 5;
x = count--; //x is assigned the value 5 then count is decremented by 1
Print: x; //output 5
Print: count; //output 4
```

The above code is equivalent to

```
count = 5;
x = count; //first x is assigned the value
count = count-1; //then count is decremented
Print: x;
Print: count;
```

First decrement then use the value.

Example

```
count = 5;
x = --count; //count is decremented by 1 then x is assigned the value 4
Print: x; //output 4
Print: count; //output 4
```

The above code is equivalent to

```
count = 5;
count = count-1; //first count is decremented
x = count; //then x is assigned the value
Print: x;
Print: count;
```

It is used to get the remainder.

Example

```
5 % 2 = 1 //dividing 5 by 2 we get remainder 1
4 % 6 = 4 //dividing 4 by 6 we get remainder 4
12 % 12 = 0 //dividing 12 by 12 we get remainder 0
```

**Logical ADD &&**

If both operand are TRUE then output is TRUE

**Logical OR ||**

If any one operand is TRUE then output is TRUE

**Logical NOT !**

Complements the value.

Converts TRUE to FALSE and FALSE to TRUE

Converts 1 to 0 and 0 to 1

A | B | A && B |
---|---|---|

FALSE | FALSE | FALSE |

FALSE | TRUE | FALSE |

TRUE | FALSE | FALSE |

TRUE | TRUE | TRUE |

A | B | A && B |
---|---|---|

0 | 0 | 0 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 1 |

A | B | A || B |
---|---|---|

FALSE | FALSE | FALSE |

FALSE | TRUE | TRUE |

TRUE | FALSE | TRUE |

TRUE | TRUE | TRUE |

A | B | A || B |
---|---|---|

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 1 |

A | A! |
---|---|

FALSE | TRUE |

TRUE | FALSE |

A | A! |
---|---|

0 | 1 |

1 | 0 |

**Is Less than <**

`Example: 5 < 6 //result TRUE`

`Example: 6 > -9 // result TRUE`

`Example: 0 <= 10 // result TRUE`

`Example: 0 >= -100 // result TRUE`

`Example: 7 == 8 // result FALSE`

`Example: 7 != 8 // result TRUE`

We generally divide array in three category:

- One-Dimension array
- Two-Dimension array
- Multiple-Dimension array

If we have an array by the name arr which has n elements then we’ll represent this array as arr[0:n-1]

Note!

In programming languages like C, C++, Java etc. array index starts from 0.

So for an array with n elements we will have

starting index = 0

and

ending index = n-1

When converting your pseudo code into programming language code take special care of the array index.

An array by the name arr with r rows and c columns will be represented as arr[0:r-1][0:c-1]

Note!

In C, we declare 2D array with r rows and c columns as

`int arr[r][c];`

The row index is from 0 to r-1 and column index is from 0 to c-1

- Find XOR of 1 to n Programming
- Finding nth Fibonacci number Programming
- Number Conversion - Binary Octal Hexadecimal Conversion
- Octal to Decimal conversion of an integer number Conversion
- How to install RabbitMQ on Mac using Homebrew How to Mac
- What is EMI? Money
- What is Recurring Deposit? Money
- What is Fixed Deposit? Money
- Sum of Products and Product of Sums Boolean Algebra
- How to install Apache, MySQL, PHP on macOS Mojave 10.14 How to Mac