Friday, April 2, 2010

Lesson 03 – Variables

So far you have learned how to write a simple program using basic C++ concepts. Here going to discuss about the variables in C++. Variables used to store data and their existing various types of variables (Eg: char, int, float etc) to store different types of information. Each of these variable types is each a keyword that you use when you declare a variable. Using the right variable type can be important for making your code readable and for efficiency.

The syntax used to declare a variable is "type ;".

Eg: char letter;

float the_float;

int a, b, c, d;

A variable in C++ must be declared (the type of variable) and defined (values assigned to a variable) before it can be used in a program. In C++, all language keywords, all functions and all variables are case sensitive. So word ball and Ball are different keywords.

Scope of variables:

The scope of a variable can be classified in to two categories naming global and local variables.

Local variables - Local variables can be only accessed within the code itself and not outside of the function. So the scope of a local variable is limited to the function in which the variables are declared.

Global variables – Global variables can be used within and outside of any function in the program. To cater this requirement the variables are declaring outside of a function block.

For Eg:

#include

using namespace std;

int iValue1 = 1; // Global variable

int iValue2 = 2; // Global variable

int main()

{

char zCh('B'); // Local variable

cout << "Value of global variable iValue1:" << iValue1 << endl;

cout << "Value of global variable iValue2:" << iValue2 << endl;

cout << "Character in local variable zCh: " << zCh << endl;

int sum, number = 3; // Local variables with and without initialization

sum = number + 5;

cout << "Value of sum: " << sum << endl;

getchar();

return 0;

}

Friday, January 29, 2010

Lesson 02 : An example C++ Program

The most efficient way to start learning a programming language is to write programs. C++ program consists with collection of commands (commands can be either functions or keywords) and those are called C++ source code. C++ gives common functions and keywords which can be used throughout the programming.

Let us start our tour of C++ with a simple program. Here is a simple program which outputs a line of text.

// My first C++ program

#include

using namespace std;

int main()
{
cout << "Hello World!" << endl;
return 0;
}

// My first C++ program - This is a comment in C++ language. Comments can also be written starting with a slash followed by a star, and ending with a star followed by a slash. Those don’t have any effect on the program and used to enhance the readability of the program.

#include - This statement call for the inclusion of a header file to the program. A header file consists with pre defined functions and variables. Those can be used more than one program. So this is a preprocessor directive. This is for the declarations of the basic standard input-output library in C++ and tells the preprocessor to include the iostream standard file.

using namespace std; - By using this compiler can use group of functions in the standard library (std). Here you are including a namesscape to your program where all the elements of the standard C++ library are declared. The semicolon is a part of the program and it is a part of the syntax of C++. By using a semicolon you are telling the compiler that you came to the end of a particular command.

int main() – C++ programs are collection of functions and this is the main function in a particular program. Each and every program in C++ has only one main function and many other functions. This is the starting point of an execution of a program, independently of its location within the source code.
The word main is followed by a pair of parentheses and it is the function declaration in C++. Right after the parentheses finds the body of the main function followed by braces. The body of the function consists with what the function does when it is executed. Key word int is used to specify the return type of the function. This returns an integer type.

cout << "Hello World!" << endl; - This is a statement in a C++ program. This gives a visible effect in the program by outputting “Hello World!"”. As Described earlier this should also finished using a semicolon to inform the end of the statement. cout is used to declare the standard output stream in C++. This insert a sequence of characters into the standard output stream.

Operator << is the insertion stream operator. It sends contents of variable on its right to the object on its left. In our case, right operand is the string “My first C++ program” and left operand is cout object. So it sends the string to the cout object and cout object then displays it on the output screen.

endl is the line feed operator in C++. It acts as a stream manipulator whose purpose is to feed the whole line and then point the cursor to the beginning of the next line. We can use \n (\n is an escape sequence) instead of endl for the same purpose.

return 0; - This is the function return statement. This causes the main function to finish. This statement exits the function main indicating its completion and returns the value 0 to the operating system indicating that the program successfully ran to completion. It returns a variable or value to the process that calls this function.

Wednesday, January 13, 2010

Lesson 01 : Introduction to C++

C++ is an "object oriented" programming language based on the C language created by Bjarne Stroustrup of AT&T Bell Laboratories in the early 1980's and released in 1985. C++ is rich with many important features such as reusability and extensibility.

C++ is a superset of C and most carefully written ANSI C will compile as C++. The American National Standards Institution (ANSI) provides "official" and generally accepted standard definitions for C and C++. A program written only in ANSI C++ is guaranteed to run on any computer whose supporting software conforms to the ANSI standard.

It is must to have a compiler for each and every programming language. Compiler is a communication medium and it is capable of filling the gap between humans and the computer languages. So compiles take the source code written using high-level languages (Eg: C, C++ etc) and convert into machine language. Most of the compilers embedded in frameworks of software development tools and libraries. Some compiles can be downloaded free while some required payments. Here listed some of the compiles can be used for C++.

Downloaded for free:
• Apple C++
• Bloodshed Dev-C++
• Borland C++
• Cygwin (GNU C++)
• Digital Mars C++
• DJ Delorie's C++ development system for DOS/Windows (GNU C++)
• GNU CC source
• IBM C++
• Intel C++ for linux
• The LLVM Compiler Infrastructure
• Microsoft Visual C++ 2008 Express edition.
• Sun Studio

Require payment:
• Borland C++
• CodeWarrior C++
• Comeau C++
• Edison Design Group C++ Front End
• Green Hills C++
• HP C++ for Unix and HP C++ for OpenVMS
• Intel C++
• Mentor Graphics/Microtec Research C++
• Microsoft C++
• Paradigm C++
• The Portland Group C++
• SGI C++
• Sun C++
• WindRiver's Diab C++

For the front end developments it requires a frontend environment. Most common environment used for the C++ language is Dev-C++ around GNU's G++ compiler.

Tuesday, June 23, 2009

Hope for poor - Sasrutha

SOFTWARE APPLICATION FROM UNIVERSITY OF MORATUWA FOR EASY MANAGEMENT OF MICRO FINANCE - http://www.sasrutha.uom.lk/


Through Microfinance, unemployed women can be helped to generate an additional income to the family by involving themselves in home-based ventures. With the credit facilities given, they can initiate small scale businesses of producing various items for sale. However, supplying these women with credit facilities alone is not adequate to empower them as they will be confronted with problems of selling their products and also fulfilling loan liabilities on time without getting blacklisted. It will be more effective, if these women could be helped in finding potential buyers for their products. Having a system whereby these women could be informed of due dates of loan settlements etc. will facilitate smooth functioning of the microfinance setup. Another problem faced by many such organizations is the difficulty in uniform distribution of available aids to the deserving women whenever such aids are received. Going from house to house in search of defaulters daily is another daunting task for the staff of microfinance institutes.
The MashUp application “Hope for poor - Sasrutha” developed by University of Moratuwa students will assist both parties involved; microfinance institutes and the women to be empowered, in all these endeavours.

The main features of this MashUp are as follows.
1. Locating deserving women in aid distribution
2. Indication of the shortest path connecting debtors who are supposed to pay instalments each day( this will assist field officers in their collection trips)
3. Locating the defaulters and finding the reasons behind the defaults.
4. Checking on all the relevant details of clients as and when it is needed. As the information is shown graphically, it enables the staff to analyze effective loan to saving ratios.
5. Researchers and NGOs too will find this MashUp application helpful in their operations.
6. Most importantly, this MashUp “Hope for poor - Sasrutha” will support different languages based on the user preference.

For further details visit : www.sasrutha.uom.lk




Source : http://www.free-press-release.com/news/200906/1245039821.html

Wednesday, June 17, 2009

Hibernate




Hibernate
•Hibernate maps the Java classes to the database tables.
•It also provides the data query and retrieval facilities that significantly reduces the development time.
•Hibernate is not the best solutions for data centric applications that only uses the stored-procedures to implement the business logic in database. It is most useful with object-oriented domain modes and business logic in the Java-based middle-tier.
•Hibernate allows transparent persistence that enables the applications to switch any database.
•Hibernate can be used in Java Swing applications, Java Servlet-based applications, or J2EE applications using EJB session beans.
•Eclipse support, including a suite of Eclipse plug-ins for working with Hibernate 3.0, including mapping editor, interactive query prototyping, schema reverse engineering tool.
•Hibernate is Free under LGPL: Hibernate can be used to develop/package and distribute the applications for free.
•Hibernate is Scalable: Hibernate is very performant and due to its dual-layer architecture can be used in the clustered environments.
•Less Development Time: Hibernate reduces the development timings as it supports
•inheritance, polymorphism, composition and the Java Collection framework.
•Automatic Key Generation: Hibernate supports the automatic generation of primary key for your.


The above diagram shows that Hibernate is using the database and configuration data to provide persistence services (and persistent objects) to the application.
To use Hibernate, it is required to create Java classes that represents the table in the database and then map the instance variable in the class with the columns in the database. Then Hibernate can be used to perform operations on the database like select, insert, update and delete the records in the table. Hibernate automatically creates the query to perform these operations.

Hibernate architecture has three main components:
•Connection Management
Hibernate Connection management service provide efficient management of the database connections. Database connection is the most expensive part of interacting with the database as it requires a lot of resources of open and close the database connection.

•Transaction management:
Transaction management service provide the ability to the user to execute more than one database statements at a time.

•Object relational mapping:
Object relational mapping is technique of mapping the data representation from an object model to a relational data model. This part of the hibernate is used to select, insert, update and delete the records form the underlying table. When we pass an object to a Session.save() method, Hibernate reads the state of the variables of that object and executes the necessary query.

Hibernate is very good tool as far as object relational mapping is concern, but in terms of connection management and transaction management, it is lacking in performance and capabilities. So usually hibernate is being used with other connection management and transaction management tools. For example apache DBCP is used for connection pooling with the Hibernate.

Hibernate provides a lot of flexibility in use. It is called "Lite" architecture when we only uses the object relational mapping component. While in "Full Cream" architecture all the three component Object Relational mapping, Connection Management and Transaction Management) are used.


Source : http://www.roseindia.net/hibernate/index.shtml

Wednesday, March 18, 2009

Sinharaja



Sinharaja is located in south-west Sri Lanka and it is a rain forest. t is bounded on the north by the Napola Dola and Koskulana Ganga, on the south and south-west by the Maha Dola and Gin Ganga, on the west by the Kalukandawa Ela and Kudawa Ganga and on the east by an ancient footpath near Beverley Tea Estate and by the Denuwa Kanda. 6°21'-6°26'N, 80°21'-80°34'E . It’s a world heritage and most of the foreigners love to visit Sinharaja.

Source :
http://www.environmentlanka.com/sinharaja.html
http://www.srilanka.com/travel/traveldetail/TL00260

Sunday, February 22, 2009

Major Researches in HCI

The study of HCI is an area something widely spread. Produce usable and safe systems as well as functional systems is the basic goal. This goal can be directly applied for the website development. Some websites are easier to use than others.

Eye movements tracking and get the use of it is now discussed among each and every people in the research areas. It is very much important to improve the Human Computer Interface systems for people who are severely paralyzed or who are unable to move or control any parts of their bodies except for their eyes. Another emerging area in the HCI is hand gesture recognition. The applications are always communicative and manipulative. Communicative is the recognition of the sign language and the manipulative is the controlling robots without any physical contact between human and computer.

Speech recognition is another emerging field in HCI. There is a big gap between a talking computer and a person. The person has the ability to understand the ideas and emotions conveyed through speech but the computer doesn’t. This is a major problem in the area of Artificial Intelligence. The ultimate goal of the speech synthesis, as with all AI applications, is to make it pass the Turing Test - a blindfolded user shouldn't be able to tell whether he is talking to a human or a machine.