Sunday, February 24, 2013

Earn Money Online - How to Make Money Online


Earn Money Online - How to Make Money Online?



Its simple and easy just follow some steps and start earning...

click on below link and start earning.

Create a Blog into Blogger.com
and choose an appropriate topic and start posting on your blog
follow Google Policies
Try to approve your google adsense account for start earning
Saturday, February 23, 2013

Arrays in PHP - How to create an Array in PHP - Types of array in PHP


Arrays in PHP - How to create an Array in PHP - Types of array in PHP
Arrays are the special variables in PHP which can store more then one value into a single variable. In PHP a array() function is used to create an array.The PHP array can store any kind of value into it and combination of different type of values into the array variable.

Example for creating an array in PHP:-

<?php

$colors=array("red","green","blue","white","black");
?>

Example for printing an array in PHP:-


<?php

$colors=array("red","green","blue","white","black");
echo $colors[0].",".$colors[1].",".$colors[2].",".$colors[3].",".$colors[4];

?>

There are three types of array in PHP:-


  • indexed array.
  • associative array.
  • multidimensional array. 
Indexed array :- arrays with numeric index or you can say these type of arrays are similar to the c, java's array.

>>two way to creating the indexed arrays in PHP

<?php
$colors=array("red","green","blue");
?>

<?php
$colors[0]="red";
$colors[1]="green";
$colors[2]="blue";
?>

Associative array :- arrays with a key which is associative with each  value.

>>two way to creating the associative arrays in PHP

<?php
$colors=array("1"=>"red","2"=>"green","3"=>"blue");
?>

<?php
$colors['1']="red";
$colors['2']="green";
$colors['3']="blue";
?>

printing an associative array:

<?php
$colors=array("1"=>"red","2"=>"green","3"=>"blue");
echo $colors['1'].",".$colors['2'].",".$colors['3'];
?>

Multidimensional array :- An array which can contain another array as a value is called multidimensional array. we can create two or three dimensional array as well.

Constructing multi-dimensional array:-

<?php
$colors=array
(
array("1"=>"red","2"=>"white");
array("3"=>"green","4"=>"blue");
);
?>






Switch Statement in PHP - How to use Swich Case in PHP


Switch Statement in PHP - How to use Swich Case in PHP

Switch Statement is used to choose one of the statement from many of choices. It is used to give a menu driven output to the user.

Syntax to use switch case statement in php.

<?php

switch(choice)
{
case label1:
statement;

case label2:
statement;
................
...............
...............

case labelN:
statement;
default:
code which should be execute if any of choice is not matched.



}
?>
Example:

<?php
$code=1;
switch($code)
{
case 1:
echo "Red";
break;
case 2:
echo "Green";
break;
case 3:
echo "Blue";
break;
default:
echo "wrong code";
}

?>


Tuesday, February 19, 2013

Operators in PHP - List of Operators in PHP, How to use Operators in PHP


Operators in PHP - List of Operators in PHP, How to use Operators in PHP

Symbols which are used to perform some types of operation on operands are called operators the php support all king of operators which are used in other languages. The following type of operators are php support-


  • Arithmetic Operators
  • Assignment Operators
  • Increment/Decrements Operators
  • Comparison Operators
  • Logical Operators
  • Array Operators   

Arithmetic Operators :-

(+) Operator - Used to add two integers or real numbers.
(-) Operator - Used to subtract two integers or real numbers.
(*) Operator - Used to multiply two integers or real numbers.
(/) Operator - Used to add divide integers or real numbers.
(%) Operator - Used to find Remainder of two integers or real numbers.

Assignment Operators:-

(=) Operator - used to assign a value to a variable.
(+=) Operator - used to add two variables and store it to a variable.
(-=) Operator - used to subtract two variables and store it to a variable.
(*=) Operator - used to multiply two variables and store it to a variable.
(/=) Operator - used to divide two variables and store it to a variable.
(%=) Operator - used to find remainder of two variables and store it to a variable.


Increment/Decrements Operators:-

(x++) - used for Post Increment.
(++x) - used for Pre Increment.
(x--) - used for Post Increment.
(--x) - used for Pre Increment.





String Variables in PHP - PHP Strings with Example - How to Concatenate Strings in PHP


String Variables in PHP - PHP Strings with Example - How to Concatenate Strings in PHP 

As you know the PHP is loosely typed programming language and there is no data types so the simple variables are used to store the string in PHP and there are number of methods/functions for manipulate the string variables further.

For Example:-

<?php
$str="Hello PHP String";
echo $str;
?>

String Concatenation in PHP:-

As like other languages like Java, C# the php does not use the (+) symbol for concatenation of two or more strings here the (.) symbol used for this purpose.
Example:-

<?php
$str1="Hello";
$str2="PHP";
echo $str1.$str2;
?>



Variables Scope in PHP - Availability of Variables in PHP program - PHP Variables Scope


Variables Scope in PHP - Availability of Variables in PHP program - PHP Variables Scope 

There are 3 types of Variables Scope available in PHP. The Scope concern the variables availability for their use in our program-


  • local
  • global
  • static
Local Scope :- To know about local scope of a variable you need to see an example so i am showing a good example to you.

<?php
$x;  //global scope

function show()
{
$str="Hello PHP"; //local scope can't be access outside the function
echo $str;
}

?>

Global Scope:- To know about global scope of a variable you need to see an example so i am showing a good example to you.

<?php
$x="Hello Global";  //global scope

function show()
{
$str="Hello PHP"; //local scope can't be access outside the function
echo $str;
echo global $x;    //global keyword is used to access global variables
}

?>

Static Scope:- When a function work is completed normally its variables values are deleted but if you want the function's variables should not delete and remain its previous values then we use the "static" keyword before declaring it.
Example:-

<?php
$x="Hello Global";  //global scope

function show()
{
$str="Hello PHP"; //local scope can't be access outside the function
static $x=0;
$x++;
}
show();
show();
show();
?>

According to the above example the show() function's variable x's last value is 3 because it is static variable.

How to Declare Variables in PHP - PHP Variables Creation


How to Declare Variables in PHP - PHP Variables Creation

As like all other languages the purpose of variables in PHP is same. As like C, C++, C#, Java and VB the variables are used to store the values.

But as like C, C++, C#, Java and VB the PHP variables are not strictly typed, In PHP the variables are loosely typed and and no need to specify the Data Types of any variable at the time of declaration. The PHP variables implicitly convert to its assigning values.

The PHP variables should start with $ sign whenever they used.

For Example:-

<?php
$str;
$x=10;
$str="Hello PHP Variables";
$y=10.5;
echo $str;
echo $x;
echo $y;
?>




Simple Program in PHP - PHP Syntex of a Program, How to write a simple Program in PHP


Simple Program in PHP - PHP Syntex of a Program, How to write a simple Program in PHP

There are two ways to work with PHP one is to write PHP scripts into <?php ------some code-----?> and second is <? -----some code----?> .
I am suggest you to use the first one because the second one is not supported all scripts so lets come to how to write a simple program in PHP.

<html>
<head>
<title>Simple Program in PHP</title>
</head>
<body>
<?php
echo "Welcome to the World of PHP";
?>
</body>
</html>

the PHP script can be placed any where into our program like i am using it into the body section. It depends on your requirement.


Monday, February 18, 2013

How to Install PHP - PHP Installation - Download WAMP Server for PHP


How to Install PHP - PHP Installation - Download WAMP Server for PHP

To work with PHP you need to install a Web Server, PHP and MySql.


Download Apache Tomcat Web Server from apache website  
Download PHP from PHP website
Download MySql from MYSql Site

If you don't want to download these 3 software's then another Alternative is download the WAMP Server, The WAMP server has all three software's in one package.

Download WAMP Server from Wamp website
you need to download a small software

Microsoft Visual C++ 2010 SP1 Redistributable Package from Microsoft website


first install the 

Microsoft Visual C++ 2010 SP1 Redistributable Package and then install the WAMP Server

Now you are ready to work with PHP
Write your Program with extension .php and place it to your web directory 
Friday, February 15, 2013

Operator Overloading in C++ - What is Operator Overloading


Operator Overloading :-
                             Operator Overloading is a technique to overload an operator with assigning a additional operation to it for example if we want to add two numbers then simply we use the (+) operator but if we want to add two strings objects with (+) operator then we need to overload it.

In C++ the operator overloading is very easy and very efficiently.

We can overload some of the operators not all operators.

Example to overload a binary operator in C++


What is Method Overriding - Method Overriding in Java, What is Runtime Polymorphism in Java


What is Method Overriding - Method Overriding in Java, What is Runtime Polymorphism in Java

Method Overriding is a technique to override a existing task from a method and assign a new task to that method. or one or more method with same name and same signature into two or more classes and every method gives its own definition.The method overriding only be achieve by the help of inheritance and two or more classes.
The Method Overriding sometimes called Runtime Polymorphism.


Example 


interface DrawShape

public void draw();
}

class Circle implements DrawShape
{
public void draw()
{
System.out.println("You are in Circle class");
}


class Triangle
{
public void draw()
{
System.out.println("You are in Triangle class");
}
}

In above example i made an interface with draw() method and then implements that method into two classes and each class define draw() method according to its requirement.

Method Overloading in Java - What is Overloading, What is Compile Time Polymorphism


Method Overloading in Java - What is Overloading, What is Compile Time Polymorphism
                    Method Overloading is a kind of technique in Polymorphism. It is a technique to assign multiple task to a method or when one or more methods with same name but different signature in one or more classes are exist then this methodology is called Method Overloading.

In general life if a person is doing more then one works then those person has overload work but if that person is able to do all works assigning to him then it is very beneficial for that organization in which that person works and organization take the financial benefit. 

Example of Method Overloading in Java :-

class TestOverload
{
public int sum(int x,int y)
{
return (x+y);
}

public int sum(int x,int y,int z)
{
return (x+y+z);
}

public double sum(double x,double y)
{
return (x+y);
}


}

In above Example the "sum()" method doing the three task sum of two integer numbers, sum of three integer numbers, sum of tho real numbers.

Inheritance in Java - Java Inheritance with Example


Inheritance :-
                    Inheritance is the ability to re-use the code of existing object or class. It is very powerful feature of Oops. It help to reduce the code and maximize the simplicity in our program.

For Example - In our real life a human is a good example of inheritance because a child has some features which are inherited from his/her parents like height, color, behavior etc.

In Programming Inheritance can achieve by the help of following techniques--


  • Single Inheritance
  • Multilevel Inheritance.
  • Multiple Inheritance.


Wednesday, February 13, 2013

StringsBuffer Class in Java - Use of StringBuffer Class in Java


StringBuffer Class in Java:-

The StringBuffer Class is an alternative to the String Class. In General a StringBuffer can be used wherever a String class is used.

StringBuffer is more flexible then String class. You can add, insert or append new contents into a StringBuffer class object.However the value of a String object is fixed once the string is created.

Example:-


StringBuffer str="Hello StringBuffer";
str.toUpper();

the above program output come like as-
HELLO STRINGBUFFER

it is only possible with StringBuffer not with the String class.

Pointers in C Language - Use of Pointers in C, How to create a pointer in C, C++


Pointers in C Language - Use of Pointers in C, How to create a pointer in C, C++

Pointers are nothing but a special variable which are hold the address of another variable or another pointer variable.
same like as a simple variable, a simple variable hold the value but a pointer hold the address.

Creating Pointer variables in C:- To create a pointer variable in C you should use the * sign before variable name.
Example

int *p1;
float * p2;
char *p3;


Initialize pointer variables in C:-

int *p1;
int x;
p1=&x;

Printing the value of a Pointer in C:-

int *p1,x=10;
p1=x;
printf("%d",*p1);

Spring MVC Tutorial - What is Dependency Injection


Spring MVC Tutorial - What is Dependency Injection

Dependency Injection is a Software design Pattern that allows removing hard-coded dependencies and making it possible to change them, whether at run-time or compile-time.

When an Object is created in Spring Framework it is not necessary to call it explicitly like for example i am making two classes here.

Class1 :-

public class Test
{
public void showMessage()
{
System.out.println("Hello World");
}
}

now i make an another class for calling the showMessage() method.

public class TestRun
{
public static void main(String st[])
{
Test t=new Test();
t.showMessage();
}
}

The above method is hard coding method to create an Object explicitly but the Spring Framework provide certain classes for doing this automatically with the help of a XML file this technique is called Dependency Injection 


to do this we need to change the TestRun class as below.



public class TestRun
{
public static void main(String st[])
{
BeanFactory factory=new XmlBeanFactory(new FileSystemResourse("spring.xml"));
Test t=(Test)factory.getBean("test");
t.showMessage();
}
}

Now we need to map the bean into XML file like this.



<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans SYSTEM "http://www.springframework.org/dtd/spring-beans-2.0.dtd" PUBLIC "-//SPRING//DTD BEAN 2.0//EN">

<beans>
<bean id="test" class="Test"/>

</beans>




Program for checking a Number is Perfect Number or Not in C, Java and C#




Program for Checking a Number is Perfect Number or Not :-

Program in C :-

#include<stdio.h>
#include<conio.h>
void main()
{
int num,a,num2=0,num3;
printf("Enter a Number \n");
scanf("%d",&num);
num3=num;
while(num>0)
{
a=num%10;
num2=num2+a;
num=num/10;
}
if(num2==num3)
printf("Number is Perfect");
else
printf("Number is not Perfect");
getch();
}


Program in Java :-


public class TestNumber
{
public sttaic void main(String args[])
{
int num,a,num2=0,nu3;
System.out.println("Enter a Number");
Console con=System.console(System.in);
num=Integer.parseInt(con.readLine());
num3=num;
while(num>0)
{
a=num%10;
num2=num2+a;
num=num/10;
}
if(nun2==num3)
System.out.println("Number is Perfect");
else
System.out.println("Number is not Perfect");
}
}


Program in C# :-


public class Test
{
public static void Main()
{
int num,a,num2=0,num3;
Console.WriteLine("Enter a Number");
num=Integer.Parse(Console.ReadLine());
num3=num;
while(num>0)
{
a=num%10;
num2=num2+a;
num=num/10;
}
if(num2==num3)
Console.WriteLine("Number is Perfect");
else
Console.WriteLine("Number is not Perfect");
}
}

Program for Checking a number is Armstrong or not in C, Java and C#



Program for Checking a Number is Palindrome or Not :-

Program in C :-

#include<stdio.h>
#include<conio.h>
void main()
{
int num,a,num2=0,num3;
printf("Enter a Number \n");
scanf("%d",&num);
num3=num;
while(num>0)
{
a=num%10;
num2=num2+(a*a*a);
num=num/10;
}
if(num2==num3)
printf("Number is Armstrong");
else
printf("Number is not Armstrong");
getch();
}


Program in Java :-


public class TestNumber
{
public sttaic void main(String args[])
{
int num,a,num2=0,nu3;
System.out.println("Enter a Number");
Console con=System.console(System.in);
num=Integer.parseInt(con.readLine());
num3=num;
while(num>0)
{
a=num%10;
num2=num2+(a*a*a);
num=num/10;
}
if(nun2==num3)
System.out.println("Number is Armstrong");
else
System.out.println("Number is not Armstrong");
}
}


Program in C# :-


public class Test
{
public static void Main()
{
int num,a,num2=0,num3;
Console.WriteLine("Enter a Number");
num=Integer.Parse(Console.ReadLine());
num3=num;
while(num>0)
{
a=num%10;
num2=num2+(a*a*a);
num=num/10;
}
if(num2==num3)
Console.WriteLine("Number is Armstrong");
else
Console.WriteLine("Number is not Armstrong");
}
}

How to Check a number is Palindrome or Not in C, Java and C#


Program for Checking a Number is Palindrome or Not :-

Program in C :-

#include<stdio.h>
#include<conio.h>
void main()
{
int num,a,num2=0,num3;
printf("Enter a Number \n");
scanf("%d",&num);
num3=num;
while(num>0)
{
a=num%10;
num2=num2*10+a;
num=num/10;
}
if(num2==num3)
printf("Number is Palindrome");
else
printf("Number is not Palindrome");
getch();
}


Program in Java :-


public class TestNumber
{
public sttaic void main(String args[])
{
int num,a,num2=0,nu3;
System.out.println("Enter a Number");
Console con=System.console(System.in);
num=Integer.parseInt(con.readLine());
num3=num;
while(num>0)
{
a=num%10;
num2=num2*10+a;
num=num/10;
}
if(nun2==num3)
System.out.println("Number is Palindrome");
else
System.out.println("Number is not Palindrome");
}
}


Program in C# :-


public class Test
{
public static void Main()
{
int num,a,num2=0,num3;
Console.WriteLine("Enter a Number");
num=Integer.Parse(Console.ReadLine());
num3=num;
while(num>0)
{
a=num%10;
num2=num2*10+a;
num=num/10;
}
if(num2==num3)
Console.WriteLine("Number is Palindrome");
else
Console.WriteLine("Number is not Palindrome");
}
}

How to check a number is Even or Odd in C, Java and C#


Program for Check a Number is Even or Odd :-

Program for C :-

#include<stdio.h>
#include<conio.h>
void main()
{
int num;
printf("Enter a Number \n");
scanf("%d",&num);
if(num%2==0)
printf("Number is Even");
else
printf("Number is Odd");
getch();
}

Program in Java :-

public class TestNumber
{
public sttaic void main(String args[])
{
int num;
System.out.println("Enter a Number");
Console con=System.console(System.in);
num=Integer.parseInt(con.readLine());
if(num%2==0)
System.out.println("Number is Even");
else
System.out.println("Number is Odd");
}
}


Program in C# :-

public class Test
{
public static void Main()
{
int num;
Console.WriteLine("Enter a Number");
num=Integer.Parse(Console.ReadLine());
if(num%2==0)
Console.WriteLine("Number is Even");
else
Console.WriteLine("Number is Odd");
}
}


Why Java is Plateform Independent, How java achieve the platform independency


Why Java is Plateform Independent, How java achieve the platform independency


Before knowing "why Java is Platform independent" we should know about the term "Platform Independence".

Any of the program which is written in any of the programming language can be execute on any other machine whether the first machine and second machine has totally different Hardware and Software like Processor and Operating System without re-compile it, is called Platform Independence.

Now come on to the topic Java is Compiled and Interpreted Language means a java program's compilation and execution happen in two stages first we need to compile it with the help of "javac" compiler and after compilation the java source code compile into the .class file and the java .class file can be executed on any of the other machine with the help of java interpreter which is "java" and the one condition is applied the Java Virtual Machine (JVM) should be there into that machine.

Spring Framework Download - Spring Framework and its all related JARs Download


Spring Framework Download - Spring Framework and its all related JARs Download

The Spring Framework is an Open Source application Framework and inversion of control container for the java platform  It is developed by Rod Johnson in 2003. Spring is a Complete and a modular framework, means spring framework can be used for all layer implementation for a real time application. 


To Use The Spring Framework you need an IDE like Eclipse, Net Beans or any other. and need to be install the Spring Framework JARs which contains the all API's related to the Spring.

Download The Spring Framework from 

the official site of Spring Framework

Data Types in C - List of Data Types in C Language



Data Types in C Language :-

C has a concept of "Data Types" which are used to define a variable before its use. A variable is hold the value for its define data type and in a variable the value which it holds can be change during the program life cycle.

C has the following built-in Data Types--
  • int 
  • float 
  • double
  • char
Data Types in C - List of Data Types in C Language

int :- The int Data Type is used to store the integer values positive and negative both. The range of numbers in int in C is -32768 to +32767.

float :- The float Data Type used to store the floating point values positive and negative both.

char :- The char Data Type is used to store a single character in a variable. 

double :- The double Data Type is used to store the floating point numbers into a variable but it range is just double from float.



First Program of C Language - Introduction Of C Language



First Program of C Language - Introduction Of C Language
C is a general purpose High Level Programming Language developed by Dennic Ritchie for the Unix Operating System in AT & T Bell Lab in 1972.C was given free with UNIX O/S.
All the Applications which are running on Unix Operating System are developed in C and the UNIX operating System also developed in C Language.

Features of C Language :-


  • Easy to Learn.
  • High Level Language with great support of Low Level Programming.
  • Structured Language.
  • Can be Compiled on various machines with different Compilers. 

Program of C Language - How to write a C Program.

#include<stdio.h>
#include<conio.h>
int main()
{
int x=10;
printf("Your value is =%d",x);

}

What is C - Introduction of C Language - First Program in C


What is C - Introduction of C Language - First Program in C

C is a general purpose High Level Programming Language that was originally developed by Dennic Ritchie for the Unix Operating System in AT & T Bell Lab in 1972. C was provide free with the UNIX OS.

All the Applications which are running on Unix Operating System are developed in C and the UNIX operating System also developed in C Language.

Features of C Language :-


  • Easy to Learn.
  • High Level Language with great support of Low Level Programming.
  • Structured Language.
  • Can be Compiled on various machines with different Compilers.