Important Concepts

Programming

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

Semicolon

Comment

Data Item

Variable

Semicolon ;

As in English, every sentence ends with a full stop .
In programming every statement ends with a semicolon ;
Example

x = 10;

Comment

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*/

Data Item

In programming we deals with data which are of the following typesNumeric
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

Variable

To save data we need variables.

Example of 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;

Constant

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

Modulus Operator

Logical Operator

Logical ADD &&
If both operand are TRUE then output is TRUELogical OR ||
If any one operand is TRUE then output is TRUELogical NOT !
Complements the value.
Converts TRUE to FALSE and FALSE to TRUE
Converts 1 to 0 and 0 to 1

Logical ADD Operator &&

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

If both the expressions are TRUE (i.e. 1) then the output is TRUE (i.e. 1)

Logical OR Operator ||

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

If any one expression is TRUE (i.e. 1) then the output is TRUE (i.e. 1)

Logical NOT Operator !

A

A!

FALSE

TRUE

TRUE

FALSE

A

A!

0

1

1

0

Converts TRUE (i.e. 1) to FALSE (i.e. 0) and converts FALSE to TRUE

Relational Operator

Is Less than <

Example: 5 < 6 //result TRUE

Is Greater than >

Example: 6 > -9 // result TRUE

Is Less then equal to <=

Example: 0 <= 10 // result TRUE

Is Greater than equal to >=

Example: 0 >= -100 // result TRUE

Is Equal to ==

Example: 7 == 8 // result FALSE

Is Not equal to !=

Example: 7 != 8 // result TRUE

Array

We generally divide array in three category:

One-Dimension array

Two-Dimension array

Multiple-Dimension array

1D 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.

2D Array

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