Skip to main content


Divide integer and get integer value with intdiv() in PHP7

When an integer number is divided by another integer number, output will be in integer with some decimal values in PHP.

3 ways of removing decimal value with integer division.

For example, when an integer 7 is divided by 2, output will be 3.5. Decimals can be removed with PHP built in functions round() or float() as shown below.

// Usage of round function rounds it to upper integer value round ( 7/2 ) ; // gives output 4 // Usage of floor function gives the correct integer without decimals floor ( 7/2 ) ; // gives output 3
PHP 7 supports new built in function intdiv() which does same as division followed by floor() function. With the introduction of intdiv function, using floor() is not required in PHP7.

// intdiv() function in PHP7 is equivalent of integer division followed by floor() funcion in earlier versions of PHP. intdiv ( 7 , 2 ) ; // gives output 3
Please keep an eye on the syntax of intdiv ( dividend , divisor ).  It requires to use comma in place…
Recent posts

PHP tutorials

PHP is a server side general purpose scripting language, most widely used for developing web applications. It supports various databases namely MySQL, FbSQL, GeoIP, YAZ databases and so on.

Rasmus Lerdorf, a Greenlandic-Danish programmer created PHP in the year 1994. It is easy to learn. No prior programming language experience is required.

PHP file terminates with an extension .php .

Lets begin learning with an example, <!DOCTYPE HTML> <html>     <body>         <?php             echo "Hello world, PHP script goes here!!";         ?>     </body> </html>
Place the above piece of code in a file with an extension .php. When it gets executed, the text inside double quotes gets displayed on the terminal. In this example, PHP code begins with <?PHP and ends with ?>

PHP comments PHP supports both single line and multi line comments that can be embedded in a .php webpage. Single line comments begin with double forward slash or single hash an…

JavaScript Operators

JavaScript Operators are used for performing various mathematical operations.

Types of Operators
Arithmetic Operators Comparison OperatorsAssignment Operators Logical OperatorsBitwise Operators Ternary Operator or Conditional OperatorArithmetic Operators: Used for performing addition, subtraction, multiplication, division, modulus, increment and decrement operations.

OperatorDescriptionExampleInputOutput+Additiona = b + cb = 1; c = 2 ;a = 3;- Subtractiona = b - cb = 3; c = 1;a = 2;*Multiplicationa = b * cb = 2, c =2;a = 4;/Divisiona = b / c b = 4, c = 2;a = 2;%Modulusa = b % cb = 8, c = 2;a = 2;++Incrementa = ++b
a = b++b = 2;a = 3; b = 2;
a = 2; b = 3;--Decrementa = --b
a = b--b = 2;a = 1; b = 1;
a = 2; b = 1;
Comparison Operators: Used for comparing between two operand by value and also by their data types.

OperatorDescriptionExamplesInputs passed to a and bReturns below outputs==Compares the valuesa == ba = 2; b = 2;
a = 2, b = 1;true
false===compares the values and value typea =…

Single line and multi line comments in javascript

Comments plays a vital role in JavaScript that provide the information about a piece of the JavaScript.

Comments can be a single line or multi line. While debugging the large piece of code, comments can be used to prevent the execution of the code.

This tutorial explains about the single line and multi line comments.

Single Line Comments

Two forward slashes ( denoted by // ) creates a single line comment. Text written after the slashes till the end of new line, will not get executed.

Single line comments can be written before the statement of after the statement.

Before the statement.
// Declare a, assign the value of 2 var a = 2; // Declare b, assign the value of a + 1 var b = a + 1; After the statement.
var a = 2; // Declare a, assign the value of 2 var b = a + 1; // Declare b, assign the value of a + 1
Multi Line Comments

Multi line comments begins with forward slash and asterick ( denoted by /* ) and ends with asterick and forward slash ( denoted by */ ). Any text w…

File Handling in C programming language

Real time applications in C are created using the tecnique of file handling also know as file management. Files stores the group of related data. If the applocations are created without using the concept of files, the data might be lost when the system is shut down.

Basic file operations supported by C includes,

naming the filesopening the filesreading data from the fileswriting data to the filesclosing the files C library comes with important built-in functions for handling the files. 
Function NameFunction Descriptionfopen()Opens the file if exists or creates the new file.fclose()Closes the file opened by fopen() functiongetc()Used to read a single character at a time from the file putc()Prints the single character at a time in the opened filefscanf()A collection of data is read from a filefprintf()Prints the collection of data in the opened filegetw()Used to read an integer from a fileputw()Writes the integer in a filefseek()Used to set the position of cursor to the required point i…

C++ program to find the even and odd numbers

When even numbers are divided by 2, the output will be 0, modulus of odd numbers with 2 gives the output value of 1.

C++ Program to find even and odd numbers using if-else condition
#include <iostream> using namespace std; int main() { int n; cout << "Enter an integer: "; cin >> n; if ( n%2 == 0) cout << n << " is even."; } else { cout << n << " is odd."; } return 0; }

32 Keywords of C programming language

History of Keywords
There are 32 keywords in C89 language.5 more keywords were introduced in C99.7 new keywords were introduced in C11.Keywords cannot be redefined.They are already predefined for specific tasks.They are also know as Reserved Words.
List of 32 C Keywords