Friday, 27 July 2012

Generate Auto Id

Logic to generate unique id -

Create a table in the database named tbl_id and set the fields (the number of unique id’s to be generated. For Example – In Computer rental system, there is a need to generate id for both the customer and the Computer. So, two fields one for the customer and second for the computer must be set / defined. One thing to make sure is that the data type of fields must be Number)

Set the default value to 1000. (Depending on the requirement if the user wants that the id must start from 1 set the default values to 1)

On the form or the web page where unique need to be generated a select query need to be written in which the field value from the table tbl_id need to be selected. For Example – In case of customer id, select the customer_id field value from the table tbl_id by writing a query like this – SELECT customer_id from tbl_id.

Store the result obtained from this query in a variable of type integer. Now if the user wants that the id must be in a suitable format such as CS – 1000, or CUS – 1000 or whatever the format is just concatenating the prefix required with this variable. (make sure that concatenation does not change the value of the variable.

On the click of the save button or key depending on the programming language or the way the action is being performed update the value of the variable by adding 1 to it and update this variable value again in the tbl_id customer_id field.

Wednesday, 25 July 2012

Computer Rental System in Visual Basic.NET

Introduction to Java

This post has been created to present a quick overview of Java, what exactly are the features Java and writing your first Hello World Program in Java (compiling it and executing it).

Genesis of Java Language

C and C++ are the programming languages that provides a basis for Java. Java derives its syntax from C and object oriented features from C++. Later in this chapter we will discuss the reasons and the section of events that lead to the creation of Java. 

Programming Language innovation occurs to solve a fundamental problem that the preceding languages were not able to solve and java is no different.  

C Programming Evolution -

In early 1970's there was a need of a structured programming language that could replace the assembly code when creating system programs.This lead to the creation of C that shocked the programming world. Even today its power cannot be underestimated. Operating Systems like LINUX, UNIX are coded in C. Various factors need to be considered before using a programming language such as -
  • Ease of Use vs. Power
  • Safety vs. Efficiency
  • Rigidity vs. Extensibility
Before C Language, options available to programmers were FORTRAN, BASIC, COBOL, ASSEMBLY LANGUAGE. While one was easy to make scientific applications but not system programs, other was easy to learn but not powerful. They were not even structured to. GOTO was the primary means of program control (resulting in a lot of spaghetti code). While language like PASCAL was structured they were not designed for efficiency, PASCAL was not considered for systems-level code.

Sunday, 22 July 2012

Constructor/Method outside the class

Defining a constructor/method outside the class - 

      For defining a constructor or method outside the class four things should be kept in mind - 
    1. Return Type
    2. Class Name
    3. Scope Resolution Operator
    4. Constructor/Method name

Note - Constructors/Destructors don't have a return type, so while defining constructors/destructors outside the class return type is not specified.

Syntax - (return type) (class name)(scope resolution operator)(constructor/method name)

For Example - Consider the definition of class student that a constructor, method and destructor.

class student
    private : 
              int id ;
    public :
              student ( );
              void add_student ( );
              ~student ( );

Implementing constructor student ( ) outside the class -
student : : student ( )

Implementing method add_student ( ) outside the class - 
void student : : student ( )

Implementing destructor student ( ) outside the class - 
student : : ~student ( )

Saturday, 21 July 2012

Structured Query Language : Database Language

SQL - 

             SQL is known as Structured Query Language (pronounced as S-Q-L) was developed by IBM in mid-1970's. It’s a non-procedural language (i.e. one does not have to specify all the steps required to perform a action).
It’s an international language used for querying and creating relational databases (database that stores data in the form of tables i.e. rows and columns) and the most common SQL standard is SQL-92 (standard is known as SQL-92 because the standard was approved in 1992).However the standards SQL-99 extensions are used by most vendors.


              SQL command can be divided into 3 categories - 

  1. DDL 
  2. DML
  3. DCL
DDL is referred as Data Definition Language. It generally includes commands that are used for defining  a database i.e. creating, altering, dropping database, tables and establishing constraints such as primary-foreign key constraints. For Example - 
  • CREATE command is used to create a database or table. CREATE DATABASE db_admin.
  • DROP command can be used for various purposes such as deleting a database,  table or an index. DROP DATABASE db_admin.

DML is referred as Data Manipulation Language. It generally includes commands that are used for maintaining and querying a database i.e. inserting, deleting, searching or updating a record in a table. For Example - 

  • INSERT command is used to insert a new record in the table in database. INSERT INTO tbl_admin VALUES ('a','b').
  • SELECT command is used to select and view a record depending in the way query is used. SELECT * FROM tbl_admin.
DCL  is referred as Data Control Language. It generally includes commands that are used to control a database i.e. administering, privileges and committing data. For Example -
  • GRANT is used to allow specified users to perform specified tasks. GRANT SELECT ON TABLE tbl_admin TO PUBLIC.
  • REVOKE to cancel previously granted or denied permissions. REVOKE CREATE TABLE FROM testing. (testing is a role)

Thursday, 19 July 2012

Decimal Number to hexadecimal number in C

Steps to convert Decimal number into Hexadecimal number - 

  1. Divide the decimal number by 16. Treat the division as an integer division.
  2. Write down the remainder (in hexadecimal, ie. if the remainder is 12, write down "C").
  3. Divide the result again by 16. Treat the division as an integer division.
  4. Repeat step 2 and 3 until result is less than 1.
  5. The hexadecimal value is the digit sequence of the remainders from the last to first. (So if you had 001, it's 100.)

Sample Output - 

Code - 

/* Program to convert Decimal number into Hexadecimal number */



int main()
int decimal_number = 0, temp_number = 0, remainder = 0, counter = 0, i  = 0, value = 0;

char hexadecimal_number[10];

printf("\n\t __ Program to convert Decimal number into Hexadecimal number __");

printf("\n\n\n  Enter the Decimal Number - ");


temp_number = decimal_number;

while(temp_number > 1)
remainder = temp_number % 16;

temp_number = temp_number / 16;

value = 0;

if (remainder >= 0 && remainder <= 9)
value = 48;

for ( i = 1; i <= remainder; i ++)
value = value + 1;
else if (remainder >= 10 && remainder <= 15)
value = 65;

for ( i = 11; i <= remainder; i ++)
value = value + 1;

hexadecimal_number[counter] = (char)value;


printf("\n\n  Hexadecimal Conversion of %d (base 10) is ", decimal_number);

for( i =  counter - 1 ; i >= 0; i -- )
printf("%c", hexadecimal_number[i]);

printf(" (base 16)");


return 0;

Tuesday, 17 July 2012


In a multiprogramming environment, several processes may compete for a finite number of resources. Generally a process may utilize the resource in the following fashion –

ð  Request for a resource
ð  Use the resource
ð  Release the resource

But in an Operating System sometimes a situation might occur when a process enters a waiting state because a resource requested by it is being held by another process, which in turn is waiting for another resource. The above situation is known as Deadlock.

Note - If a process is unable to change its state indefinitely because the resources requested by it are being used by other waiting process, then the system is said to be in a deadlock.

Question – What can be a resource?
Answer – A resource can be anything that can only be used by a process at any instant of time.

Deadlock is a common problem in –  Multiprocessing systems,  Parallel computing,  Distributed systems

Necessary conditions for Deadlock – A deadlock situation might arise if the following conditions are held simultaneously in the system –
  1. Mutual Exclusion
  2. Hold and Wait
  3. No - Preemption
  4. Circular Wait

Sunday, 15 July 2012

Java Programming language

What is Java?
JAVA is an object oriented programming language (OOPS) which simulates the real world object in the Programming world. It is a computing platform first released by sun Microsystems in 1995. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices. 

Why should we study JAVA?
Java is a platform independent language. It is free to use. Millions of developers are there to help us when we need any help on this platform. It is safe and secure to use. We can develop our own application and sell it in the market that too without any licensing charges for the language. It has been developed very much since 1995 and many other frameworks have been added to Java ex. Spring, Hibernate etc. Today mobile based applications are being developed on Android whose base is Java. There are many reasons to choose Java apart from these.

Simple Hello World Program in Java

public class HelloWorld{
            public static void main(String args[]){
                        System.out.println("Hello World!!");
Instructions –
  1. Save the file with name
  2. Compile it with javac 
  3. And run it using java HelloWorld.