Monday, 15 December 2014

Google translator introduces Malayalam

Google has added translation service for Malayalam language also. Using this facility you can translate text from all other language supported by google translator to Malayalam and vice versa. . Google provides this facility in their site https://translate.google.co.in/ . I t will be an easiest tool to learn languages

 https://translate.google.co.in/ .








It help you to type either in Malayalam or in another language and translate it. It allows the user to contribute their own translations to improve the output.

TCExam - an Open Source Computer-Based Assessment system

TCExam is an Open Source system for electronic exams (also know as CBA - Computer-Based Assessment, CBT - Computer-Based Testing or e-exam) that enables educators and trainers to author, schedule, deliver, and report on quizzes, tests and exams. It is developed and supported by Tecnick.com LTD

Following are the features of TCExam
  •     Open Source Software
  •     Community support
  •     Platform Independent
  •     No expensive hardware requirements
  •     Internationalization (I18N)
  •     Accessibility and Usability
  •     Data Import and Export
  •     Rich Content
  •     Unique test
  •     Paper Testing with Optical Character Recognition (OMR)
It is developed using PHP for scripting and MySQL / PostgreSQL as back-end database server. Its simple and interactive installation script will provide a wizard for easy installation. It can be setup on  XAMPP, WAMP or MAMP,  or you can configure after setting up either Apache web server  or Microsoft's IIS, and MySQL or PostgreSQL server on your system.

 TCExam and  required software can be downloaded by following the links



Wednesday, 19 November 2014

How to pass variable number of arguments to a function in PHP?

In certain cases, you may require to pass different number of arguments to a function in PHP scripts. Let us consider a case where you want to calculate average of a set of values using a function. Number of values in the set may vary in each call to the function. PHP provides a mechanism to pass different number of arguments to a function and process the arguments from the function by using the following functions.

func_num_args() - Returns the number of arguments passes to the function

func_get_args() - Returns the arguments passed to the function as an array

func_get_arg($arg_num) - Returns the argument at the $arg_num th position or index . Starting index is 0.



You can see the PHP implementation of the above problem here.

Tuesday, 18 November 2014

Which are the top 10 websites in the world?



As per alexa (www.alexa.com) ranking www.google.com, worlds No. 1 search engine, is the top ranked website in the world. Second place goes to www.facebook.com, the new generation social media website.

Here is the list of top 10 websites of the world as per the records of www.alexa.com.
 

How to create your own Forms with custom Paper Sizes for Printers in Windows?

Windows provides an option to create your own Forms / Paper Size like A4, A3, etc.  with custom size and name for printing. You can add new forms to the list of Forms that will be listed in the Paper Tab of Print Dialog Box. Here is the step by step procedure for creating your own Forms.

Monday, 17 November 2014

How to apply alternate background color for rows of an HTML table using CSS

In some cases you may want to apply alternate background color for each row of an HTML table.Using CSS3 it is easy to apply alternate color for rows in an HTML table.

Create styles using CSS3 and specify background color by using nth-child(even) and nth-child(odd) selectors.


You can see the CSS3 implementation of the above problem here.

How to apply alternate background color for rows of an HTML table using PHP Script

In some cases you may want to apply alternate background color for each row of an HTML table. Using a simple script you can solve the problem. You can just apply one color for every odd row and apply another color for every even row. Check whether current row is even or odd by using a rowcount variable and check the result of rowcount mod 2  (ie. rowcount % 2) is 0 or not and change the value of background color attribute accordingly.

If rowcount % 2 is 0 then it is a even row and apply one color for that, other wise it is odd row and apply another color.

  $bgcolor = "#ffffff";
   if ($i % 2 == 0)
              $bgcolor = "#ECD23F";




You can see the PHP implementation of the above problem here.

Monday, 10 November 2014

Page wise or paginated listing of data from a database table using PHP

This example demonstrates how data from a database table  is displayed as different pages  in a webpage.

In this example records per page is stored in a variable $pagesize and it is set to 15 (you can change it as per your requirements). For each page the query is selecting only the required 15 records and displays it. 
Starting record of the given  page ($pageno) is calculated by the following expression.

 $start_rec = (($pageno-1) * $pagesize) ;

Query to select required number of records starting from start_rec is given below. To specify the starting record and number of records in SQL query the LIMIT clause is used.

Wednesday, 5 November 2014

How to read, write, update and list data from a database using Java - JDBC

JDBC is a Java database connectivity technology to access databases. This technology is an API for the Java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database A JDBC-to-ODBC bridge enables connections to any ODBC-accessible data source

The example given below demonstrate how to access a database using JDBC. In this example we uses three classes.

Sunday, 26 October 2014

Reading data from an HTML table using JavaScript

This example demonstrates how data in an HTML table can be read using JavaScript which can further be used for submitting to a server side script.

In this example, we first get the reference of the table using  the function call
var table = document.getElementById('productlist'); 
Then loop through each row of the table.
Each time data read from a cell is added to a string separated by a delimiter ( here we used "," ).
Finally the data read is displayed by using alert() function.

Entire code of this example is given below:

Friday, 17 October 2014

Use of final keyword in Java

In Java, the keyword final can be used in various contexts.  In all contexts, it prevents the modification or redefinition of the existing entity whether it is a variable, function or a class. Generally final keyword is used for the following purposes.

1.    To define constants
2.    To prevent overriding of methods
3.    To prevent inheritance

final keyword to define constants

If you want to define a constant, you can use the final keyword while declaring a variable and make it a constant.

PI is defined as a constant in the following example.

Thursday, 16 October 2014

Interface in Java

An interface can be treated as a class which contains only abstract methods (methods without body) and constants.  Interface is defined using the Java keyword interface. A class implements an interface by providing code for each method declared by the interface. By this mechanism an implementation rule or protocol is imposed on all classes they are implementing a particular interface or interfaces.

Sunday, 5 October 2014

Goodbye to Orkut!


 Google has  downed its social networking website Orkut  on September 30, 2014 and made the end of a 10-year run.

 Google says Goodbye to Orkut!

Recursive Function in C Language

Recursion is a method used to solve some problems where the solution depends on solutions to smaller instances of the same problem. The approach can be applied to types of problems for which solution can be represented recursively.

Friday, 3 October 2014

New Windows is Windows 10

Microsoft has disclosed that Windows 10 will be the next version of Windows. Windows 10 offers new experiences for customers to work, play and connect.

Windows 10 will run on broad set of devices like Mobile Gadgets, PCs and even Servers. And it is designed to use touch/pen, mouse/keyboard and controller/gesture.

And for all these devices, Microsoft provides uniform platform for application developers..
Microsoft includes the nostalgic start menu again in Windows 10 which was lost in Windows 8.

Thursday, 2 October 2014

What is an ER Diagram and how to draw it?


ER Diagram or Entity Relationship Diagram is a tool used to graphically represent the relational model of a database schema. It is a very important and useful tool that can be used in the Database Design phase of software development process to represent entities, relations, attributes, multiplicity, participation and constraints identified.  Various icons and notations are used to represent entities, relationships, attributes, multiplicity, participation and constraints are discussed below.

Tuesday, 30 September 2014

How to create a user defined exception in Java?

An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program. When an error occurs within a method (member function), the method creates an object of the error/exception and hands it off to the runtime system.

Java provides better exception handling mechanism for its programmers. It simplifies the exception handling process and gives a try .... catch ... finally stucture to handle the exception.

Sunday, 28 September 2014

Content Management System (CMS)

A Content Management System (CMS) is a web application that makes creation and management of websites very easy by making creation, modification, organization of content and publishing the website on a public or private web server.  CMSs provide a central interface to manage the website. Such systems of content management make easy handling of workflow in a collaborative environment.

Some popularly used CMSs are:

    WordPress
    Joomla
    Drupal
    Plone

Saturday, 27 September 2014

Assebmly language program to display a message

Assembly Language Programming is an indigenous programming method used for PCs. An assembly language programmer has to understand the internal architecture of the Processor and he has to program accordingly.

The program given here is a simple example for printing a message on the console.

Before going for assembly language programming make sure that you have installed TASM or MASM assembler in your system.

Then type your program using any editor and save it with an extension .asm.
(see program hello.asm.)

Thursday, 25 September 2014

C Program to check Leap Year

A leap year is a year containing one additional day in order to keep the calendar year synchronized with the astronomical or seasonal year.

For example, in the Gregorian calendar, each leap year lasts 366 days instead of the usual 365, by extending February to 29 days rather than the common 28 days.

For example:
1991 is not  a leap year.
2000  is a leap year.
1900  is not a leap year.
2004 is  a leap year.

C Program for generating Fibonacci Series

Fibonacci series is a series of integer numbers where the first two numbers in the series are 1 and 1, or 0 and 1, depending on the chosen starting point of the series, and each subsequent number is the sum of the previous two numbers  ie. Fn = Fn-1  +  Fn-2.


For example:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ….

Or

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ….

Thursday, 18 September 2014

How to create a class in Java?

This example shows how to define and use a class in Java. Let us consider a rectangle class which has two properties and four methods.

Saturday, 13 September 2014

Samsung has launched its new Phablet Galexy Note 4



Samsung has introduced its new Phablet Galexy Note 4 in a Consumer Electronics Fare, I. F. A, in Berlin, Germany. It comes with Quad HD Display -  2560 x 1440 resolution -  with AMOLED  screen. The newborn gadget is designed to compete with  Apple iPhone 6.

SanDisk Premieres World’s Highest Capacity SD Card for High Performance Video and Photo Capture

SanDisk in a press release announces the launch of the world’s highest capacity SD card (SanDisk Extreme PRO SDXC UHS-I memory card) for the video and photographic professionals.

 SanDisk Extreme Pro UHS-I SDHC/SDXC memory cards are available in various capacities like 128GB, 256GB, and 512GB worldwide. The company announced that the 512GB Extreme Pro SDXC UHS-I card will be available at $799.99 (Rs. 48,000 approximately).

Friday, 12 September 2014

C program to check if a given matrix is a sparse matrix or not

A sparse matrix is a matrix in which most of the elements are zero.

For example let us consider two matrices  A and B

Matrix A
1 0 0
1 1 0
0 1 0

Matrix B
1 1 1
0 1 0
1 0 1

Wednesday, 10 September 2014

Java Program to implement stack using array

A stack is a data structure which is a  logical representation of  a real physical stack or pile of objects, where insertion and deletion of items takes place at one end called top of the stack. The basic concept can be illustrated by thinking of the data set as a stack of plates or books where you can only take the top item off the stack in order to remove things from it. In a stack last added item is deleted first and so it is called a LIFO (Last In First Out) data structure.


C Program to implement a Queue using array

Queue 
 A queue is a a linear collection of objects, where objects are inserted and removed according to the first-in first-out (FIFO) principle. An example of a queue is a line of people in a ticket counter. New additions to the line is made to the back of the queue, while removal (or serving) happens in the front. In a queue only two operations are allowed enqueue/insert and dequeue/delete. Enqueue means to insert an item into the back of the queue, dequeue means deleting the front item. 


Tuesday, 9 September 2014

How to upload a file using PHP script



In this article let us discuss how to upload a file to a web server using PHP script. It is implemented as a function in this example in upload.php file. To upload a file, you have to create an HTML form with a file input control by using the input tag like this: "<input type=file>". 

While creating the HTML form, enctype attribute of the form should have the value "multipart/form-data". So the form tag will be like this:

<form action="upload.php" method="post"  enctype="multipart/form-data">


HTML code to crate the form


<form action="upload.php" method="post" autocomplete="off" enctype="multipart/form-data">
        <table align="center" width="100%">
           
            <tr bgcolor="#ababee">
                <td colspan="2" align="center"><h2>Upload your file</h2></td>
            </tr>
            <tr>
                <td >Select file to upload</td>
                <td ><input type="file" name="file" id="file" style="left:0;">               
                </td>
            </tr>   
                          
           
            <tr>
                <td colspan="2">               
                <input type="submit" name="upload" value="Upload">
                </td>
            </tr>                
           
        </table>       
   </form>


Database Connection using VB.Net class

This Class, implemented in VB .Net, is  used to connect and execute queries on Microsoft SQL Server database. It uses Data.SqlClient library to perform database operations.

Methods implemented in this class

C Program to implement stack using array


A stack is a data structure which is a  logical representation of  a real physical stack or pile of objects, where insertion and deletion of items takes place at one end called top of the stack. The basic concept can be illustrated by thinking of the data set as a stack of plates or books where you can only take the top item off the stack in order to remove things from it. In a stack last added item is deleted first and so it is called a LIFO (Last In First Out) data structure.


Wednesday, 3 September 2014

C Program to check a number is prime or composite

A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example, 5 is prime because 1 and 5 are its only positive integer factors, whereas 6 is composite because it has the divisors 2 and 3 in addition to 1 and 6.

Examples of prime numbers are:  2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101,.....

Let us see a function to check whether a number is prime or not.

// Function to check prime returns 0 or 1
int isprime(int value) {
    int i;
    for (i=2;i<=value/2;i++)
        if (value%i==0)
            return (0);
    return 1;
}

Here value is the number to be checked given as parameter to the function. This function returns 1 if the value prime and returns 0 if it is not.

C Program to check whether an array is sorted or not

To sort an array there are different methods. And you may be familiar with them. However, what to do if you want to simply check whether an array is sorted or not.

Method 1
Start from the beginning of the array and compare whether the 0th element is less than 1st element and so on up to the end of the array (for Ascending order). If you can move up to the end of the array without any failure in the condition, then you can assure that the array is sorted.

Method 2
You can apply the reverse logic of method 1. Initially check whether the 0th element is greater than 1st element. If this condition is true, then you can say it is not sorted without checking further.

Let us see a function using the second method to check whether an array is sorted or not.

int issorted(int array[], int len){
    int i;
    for(i=0;i<len-1;i++)
        if (a[i]>a[i+1])
            return (0); //Unsorted

    return (1); //Sorted

}

Here array[] is the actual array and len is the length of the array. This function returns 1 if the array is sorted and returns 0 if it is not sorted.

C Program to Insert an element in an array

How to insert an element in a given position in an array. It is very simple, if you want insert an element at nth position, you want to move or shift the elements right to the nth location by one place and make the nth location free. Then you can just assign the new value to the nth location.

Let us see a function implemented in C Language for inserting an element in an array.

void insert(int array[],int value,int position,int len)
{
    int i;
    for (i=len + 1 ; i>=position;i--)
        a[i]=a[i-1];
    a[position-1]=value;
    return;
}

Here array[] is the actual array where insertion is to be made. value is the new value that has to be inserted and position is the location where the value is to be inserted. len is the existing length of the array.

C Program to check Amicable Numbers

Amicable numbers are two different numbers so related that the sum of the proper divisors of first number is equal to the other number and vice-versa. (A proper divisor of a number is a positive factor of that number other than the number itself. For example, the proper divisors of 6 are 1, 2, and 3.).

For example, the smallest pair of amicable numbers is (220, 284); for the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, of which the sum is 284; and the proper divisors of 284 are 1, 2, 4, 71 and 142, of which the sum is 220.

The first few amicable pairs are: (220, 284), (1184, 1210), (2620, 2924), (5020, 5564), (6232, 6368).

Following is a C language program to check the given two numbers are amicable or not.


#include <stdio.h>
#include <conio.h>

int  main() {
    int i, sf1=0, sf2=0,  m, n;

    clrscr();
    printf("Enter the first number :");
    scanf("%d", &m);
    printf("Enter the second number :");
    scanf("%d",&n);

    if (m==n) {
       printf("Given numbers are not amicable");
       getch();
       return 0;
    }

   / * Finds sum of proper divisors of the first number (m) */
    for (i=1;i<=m/2;i++){
        if (m%i==0)
            sf1=sf1+i;
        }

 / * Finds sum of proper divisors of the second number (n) only if sum of proper divisors of first number is equal to the second number */

    if (sf1==n)
        for (i=1; i<=n/2;i++){
            if (n%i==0)
                sf2=sf2+i;
        }

     if (sf2==m)
        printf ("Given numbers are amicable");
     else
        printf("Given numbers are not amicable");

     
     getch();
     return 0;
}

Monday, 1 September 2014

Sample code for implementing "check availability option in registration form" using Ajax, PHP and MySQL



This example shows how you can include a ‘check availability’ option in a registration form using Ajax, PHP and MySQL. Using HTML input element, user enters the email id and submits to the server side PHP script ‘isavailable.php’ using Ajax. ‘isavailable.php’ script checks whether the email id is already available in the database table or not and returns the status as responseText.


checkavailability.php

This PHP file contains the form and the Ajax script to submit the email id to the server side PHP script (isavailable.php) and display the response on the page.


<!DOCTYPE html>
<html>
    <head>
        <title>Check Availability - Ajax, PHP and MySQL </title>
        <script>
        function checkavailability(){

        var xmlhttp;

        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari

            xmlhttp=new XMLHttpRequest();

        }

        else {// code for IE6, IE5

            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

        }



        xmlhttp.onreadystatechange=function() {

            if (xmlhttp.readyState==4 && xmlhttp.status==200) {

                document.getElementById("divInfo").innerHTML=xmlhttp.responseText;

            }

        }



        url = "isavailable.php";

        param = document.getElementById('txtemail').value;                       

        url = url + "?txtemail=" + param;

       

               

        xmlhttp.open("GET",url,true);

        xmlhttp.send();

    }
</script>

</head>
   
<body>


<form>
    <table align="center">
        <tr>
            <td colspan="2"><h2>Check Availability</h2></td>
        </tr>
        <tr>
        <td>Email</td>
        <td><input type="text" size="40" id="txtemail" name="txtemail"></td>
        </tr>
       
        <tr>
        <td></td>
        <td><input type="button" id="cmdcheck" name="cmdcheck" value="Check Availability" onclick="checkavailability()"></td>
        </tr>
       
        <tr>
            <td colspan="2"><div id="divInfo"></div></td>       
        </tr>
       
    </table>
</form>


</body>
</html>




isavailable.php

 This PHP file extracts the email id submitted to the server from $_REQUEST array and check whether this id is available in the table by using PHP mysql functions. The availability status is sends back to the requested page.


<?php
    $email = $_REQUEST['txtemail'];

    $dblink=mysql_connect("localhost","root","");
    mysql_select_db("dbcheckavailability", $dblink);

    $sql="SELECT * FROM tblmember WHERE email='" . $email . "';";

    $result=mysql_query($sql, $dblink);

    $responseText ="";
   
   
    if (mysql_num_rows($result)) {
        $responseText = "Sorry, <b>" . $email . "</b> is already in use!";
    }
    else {
        $responseText = "Congratulation, <b>" .  $email . "</b> is available!";
    }
  
    echo $responseText;
    mysql_close($dblink);  
?>



Table Structure

Thsis is the structure of the table that has to be created in MySQL for this example.

--
-- Database: `dbcheckavailability`
--

-- --------------------------------------------------------

--
-- Table structure for table `tblmember`
--

CREATE TABLE IF NOT EXISTS `tblmember` (
  `firstname` varchar(30) NOT NULL,
  `lastname` varchar(30) NOT NULL,
  `email` varchar(40) NOT NULL,
  UNIQUE KEY `email` (`email`)
);


INSERT INTO `tblmember` (`firstname`, `lastname`, `email`) VALUES
('anand', 'kumar', 'csnotes32@gmail.com');



Output