Tuesday, 20 December 2011

Car racing Game: Source code Step by Step - 0

I mentioned about developing car racing game earlier. So now i think i will supply the source code of it. Since it ain't small program, i'll make it several parts.
Here, i start with the main function, and next time i will add all necessary classes and its methods.
So, main function comes as follows

Wednesday, 7 December 2011

C#: System data types

C#
Shorthand
System Type
Range
Meaning in life
sbyteSystem.Sbyte -128 to 127Signed 8-bit number
byteSystem.byte 0 to 255Unsigned 8-bit
number
shortSystem.Int16 -32.768 to 32.767Signed 16-bit number
ushortSystem.UInt16 0 to 65.535Unsigned
16-bit number
intSystem.Int32 -2.147.483.648 to
2.147.483.647
Signed 32-bit
number
uintSystem.UInt32 0 to 4,294,967,295Unsigned
32-bit number
longSystem.Int64 –9,223,372,036,854,775,808
to
9,223,372,036,854,775,807
Signed 64-bit
number
ulongSystem.UInt64 0 to
18,446,744,073,709,551,615
Unsigned
64-bit number
charSystem.Char U0000 to UffffA single 16-bit
Unicode character
floatSystem.Single 1.5x10-45 to 3.4x103832-bit floating
point number
doubleSystem.Double 5.0x10-324 to 1.7x1030864-bit floating
point number
boolSystem.Boolean true or falseRepresents
truth or falsity
decimalSystem.Decimal 100 to 1028A 96-bit signed
number
stringSystem.String Limited by system memoryRepresents a
set of Unicode
characters
objectSystem.Object Any type can be stored
in an object variable
The base class of all
types in the .NET
universe

Saturday, 3 December 2011

PHP: Validating email address.

function emailValidate($email)
{
   if(!eregi("^[a-z]+[a-z0-9_-]*(\.[a-z0-9_-]+)*@[a-z0-9]+
      (\.[a-z0-9_-]+)*\.(\.[a-z]+){2,}$",$email))
  {
      return true;
  }
  return false;
}

eregi case insensitive regular expression math.

Friday, 2 December 2011

log2( x ): Binary Logarithm

In the math.h of Turbo C, binary logarithm ( log2( ) ) doesn't exists. When we are working with tree, we need to calculate depth of the tree, as well as the number of nodes in that depth.
The number of nodes in ith depth can be calculated using : 2i . formula
the max number of node in ith depth : n = 2i - 1 (complete tree).
You can use these formula to find the number of nodes in particular depth.

On the other hand, you may need to find the depth you are currently in.
There is a very easy way to do that. This is using binary logarithm to find the current depth.

...
#include <math.h>
double log2(double x)
{
       return log(x) / log(2);
}

If i made mistakes let me know
Good luck

Wednesday, 30 November 2011

PHP: data grid view

Lets demonstrate how to show data in data grid view using php.
When we are working on website, one of the most important things is to show the data in brief and in a nice way
To do that combining HTML tags along with php.
Now lets see small example

Tuesday, 29 November 2011

Binary Search

Very useful searching algorithm, in every step the number of data, which is going to be sorted will cut into half (fig 1). But keep it in your mind that it works on only sorted data.
Let N be the number of data then,
in worst case the comparison will be done log2(N) + 1 times. And in case of linear searching, the number of comparison would be N.
For example: if we are going to search a number among a million others, in the worst case scenario, the number of comparison would never be exceeded 20. But in case of linear searching algorithm, the number of comparison would be 1.000.000

Source code :

Saturday, 26 November 2011

Indian Wedding (Photos)

This is the wedding of one of the biggest college's principal's daughter. There was everything that you could possible eat in India, Most important thing is that they are all free hehe. I mean food