Month: November 2014

String

Posted on Updated on

What is String & how to use it:

The string in C programming language is actually a one-dimensional array of characters which is terminated by a null character ”. Thus a null-terminated string contains the characters that comprise the string followed by a null.

The following declaration and initialization create a string consisting of the word “Hello”. To hold the null character at the end of the array, the size of the character array containing the string is one more than the number of characters in the word “Hello.”

char greeting[6] = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’, ”};

If you follow the rule of array initialization then you can write the above statement as follows:

char greeting[] = “Hello”;

STRING COPY:

strcpy(s1, s2); Copies string s2 into string s1.

clip_image002

OUTPUT:

clip_image004

STRING CAT:

strcat(s1, s2); Concatenates string s2 onto the end of string s1.

clip_image006

OUTPUT:

clip_image008

STRING COMPARE:

Compares two string

clip_image010

OUTPUT:

clip_image012

STRING LENGTH:

strlen(s1); Returns the length of string s1.

clip_image014

OUTPUT:

clip_image016

STRING LOWER:

Converts string to lowercase

clip_image018

OUTPUT:

clip_image020

STRING UPPER:

Converts string to uppercase

OUTPUT:

clip_image024

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Advertisements

Pointer, How to use pointer

Posted on

What Are Pointers?

A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before you can use it to store any variable address. The general form of a pointer variable declaration is:

type *var-name;

type is the pointer’s base type; it must be a valid C data type and var-name is the name of the pointer variable. The asterisk * you used to declare a pointer is the same asterisk that you use for multiplication. However, in this statement the asterisk is being used to designate a variable as a pointer. Following are the valid pointer declaration:

int    *ip;    /* pointer to an integer */
double *dp;    /* pointer to a double */
float  *fp;    /* pointer to a float */
char   *ch     /* pointer to a character */

POINTER:

clip_image002

OUTPUT:

clip_image004

How to use Pointers?

There are few important operations, which we will do with the help of pointers very frequently. (a) we define a pointer variable (b) assign the address of a variable to a pointer and (c) finally access the value at the address available in the pointer variable. This is done by using unary operator * that returns the value of the variable located at the address specified by its operand. Following example makes use of these operations:

clip_image006

OUTPUT:

image

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Memory management

Posted on Updated on

Memory Allocation or Contiguous memory allocation

Main memory usually has two partitions:

 Low Memory — Operating system resides in this memory.

 High Memory — User processes then held in high memory.

Operating system uses the following memory allocation mechanism

clip_image002

a) SINGLE-PARTITION ALLOCATION

If the operating system is residing in low memory, and the user processes are executing in high memory. And operating system code and data are protected from changes by the user processes. We also need protect the user processes from one another. We can provide this 2 protection by using a relocation registers.

The relocation register contains the value of the smallest physical address; the limit register contains the range of logical addresses (for example, relocation = 100,040 and limit =74,600).

With relocation and limit registers, each logical address must be less than the limit register;

The MMU (Memory Management Unit) maps the logical address dynamically by adding the value in the relocation register. This mapped address is sent to memory.

The relocation-register scheme provides an effective way to allow the operating-system size to change dynamically.

clip_image004

Fig : HARDWARE SUPPORT FOR RELOCATION AND LIMIT REGISTERS

b) MULTIPLE-PARTITION ALLOCATION

One of the simplest schemes for memory allocation is to divide memory into a number of fixed-sized partitions. Each partition may contain exactly one process.

Thus the degree of multiprogramming is bound of partitions. When a partition is free, a process is selected from the input queue and is loaded into the free partition. When the process terminates, the partition becomes available for another process.

The operating system keeps a table indicating which parts of memory are available and which are occupied.

Initially, all memory is available for user processes, and is considered as one large block, of available memory, a hole.

When a process arrives and needs memory, operating system forms a hole large enough for this process.

clip_image006

When a process arrives and needs memory, we search this set for a hole that is large enough for this process. If the hole is to large, it is split into two: One part is allocated to the arriving process; the other is returned to the set of holes. When a process terminates, it releases its block of memory, which is then placed back in the set of holes. If the new hole is adjacent to other holes, we merge these adjacent holes to form one larger hole.

This procedure is a particular instance of the general dynamic storage-allocation problem, which is how to satisfy a request of size n from a list of free holes. There are many solutions to this problem.

The set of holes is searched to determine which hole is best to allocate, first-fit, best-fit, and worst-fit are the most common strategies used to select a free hole from the set of available holes.

First-fit:

Allocate the first hole that is big enough. Searching can start either at the beginning of the set of holes or where the previous first-fit search ended. We can stop searching as soon as we find a free hole that is large enough.

Best-fit:

Allocate the smallest hole that is big enough. We must search the entire list, unless the list is kept ordered by size. This strategy produces the smallest leftover hole.

Worst-fit:

Allocate the largest hole. Again, we must search the entire list unless it is sorted by size. This strategy produces the largest leftover hole which may be more useful than the smaller leftover hole from a best-t approach.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Linux Administration

Posted on Updated on

For system administrators, one of the perennial challenges is managing disk space and making sure that no single user takes more than his or her fair share.

It Shows how to use the quota utilities to set, monitor, and enforce file system usage quotas for individual users and for groups of users.

The programs you use to set and enforce disk usage quotas include the following:

■■edquota— Sets, edits, and removes user and group file system quotas

■■ quota— Displays defined quotas and current file system usage

■■ quotacheck— Creates, checks, and repairs file system quota files

■■ quotaoff— Disables file system quotas

■■ quotaon— Enables file system quotas

■■ repquota— Summarizes and reports on quota utilization

■■ warnquota— Checks file system usage and sends email to users who exceed their assigned quotas

Quotas are set on a per-file-system basis, rather than per disk.

The procedure for initializing quotas on file systems is straightforward. the steps to follow are:

1. Edit /etc/fstab to enable quotas on the desired file systems.

2. Create the quota accounting files on the root directory of each file system for which quotas are enforced.

3. Turn on quotas.

4. Set the desired file system quotas.

5. Review quota utilization regularly and frequently.

In the following sections, you look at each of these steps and the commands to accomplish them.

Enabling Quotas

To enable file system quotas, the first step is to drop the system to single user mode. To do so, press Ctrl+Alt+F1 to flip over to the first virtual console and then log in as root. After you have logged in, execute the following command to bring the system down to single-user mode:

# /sbin/telinit 1

The reason you should put the system into single-user mode is to prevent users from logging in and altering files.

If users alter files while you are setting up quotas, they might lose data.

Next, edit /etc/fstab and add the mount options usrquota or grpquota to the file systems on which enable quotas for users or groups, respectively.

/dev/hdb1 /data ext3 defaults,usrquota 1 2

To activate the changes you made to /etc/fstab, execute the mount command using the remount option to update the kernel’s mount table (/etc/mtab) with the quota option. For example, to activate quotas on the /data file system shown in the example, execute the following command:

# mount /home -o remount, rw

Not all quota implementations are created equal. Quota usage as described in this section assumes that you are using an ext3 file system.

Creating the Quota Files

Now that the system is prepared, the next phase of the procedure for setting up quotas is to create the accounting files quota uses to monitor file system usage.The quota accounting files are stored in the root directory of each file system.

To create these accounting files, execute the quotacheck command, as shown in the following example:

# quotacheck -uv /data

Quotacheck scans the specified file system to determine its current usage and then writes this information into the quota accounting files.

Turning on Quotas

After creating the quota accounting files, use the quotaon command to turn on quotas. quotaon’s invocation is simple

quotaon [-guv] -a | filesys

# quotaon -v /data

/dev/hdb1 [/data]: user quotas turned on

Setting and Modifying Quotas

To set quotas, use the quota editor, edquota, which has the following syntax:

edquota [-ug] -t

edquota [-ug] account

table: quotacheck Options

clip_image002

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

ASP.NET – Ajax Control

Posted on

The UpdateProgress Control:

The UpdateProgress control provides a sort of feedback on the browser while one or more update panel controls are being updated. For example while a user logs in or waits for server response while performing some database oriented job.

It provides a visual acknowledgement like “Loading page…”, indicating the work is in progress.

The syntax for the UpdateProgress control is:

<asp:UpdateProgress ID=”UpdateProgress1″

runat=”server”

DynamicLayout=”true”

AssociatedUpdatePanelID=”UpdatePanel1″ >

<ProgressTemplate>

Loading…

</ProgressTemplate>

</asp:UpdateProgress>

The above snippet shows a simple message within the ProgressTemplate tag, however it could be an image or other relevant controls. The UpdateProgress control will display for every asynchronous postback unless it is assigned to a single update panel using the AssociatedUpdatePanelID property.

Properties of the UpdateProgress Control

The following table shows the properties of the update progress control:

Properties

Description

AssociatedUpdatePanelID

Gets and sets the ID of the update panel with which this control is associated.

Attributes

Gets or sets the cascading style sheet (CSS) attributes of the UpdateProgress control.

DisplayAfter

Gets and sets the time in milliseconds after which the progress template is displayed. The default is 500.

DynamicLayout

Indicates whether the progress template is dynamically rendered.

ProgressTemplate

Indicates the template displayed during an asynchronous post back which takes more time than the DisplayAfter time.

Methods of the UpdateProgress Control

The following table shows the methods of the update progress control:

The Timer Control:

The timer control is used to initiate the post back automatically. This could be done in two ways:

(1) Setting the Triggers property of the UpdatePanel control:

<Triggers>

<asp:AsyncPostBackTrigger

ControlID=”btnpanel2″

EventName=”Click” />

</Triggers>

(2) Placing a timer control directly inside the UpdatePanel to act as a child control trigger. A single timer can be the trigger for multiple UpdatePanels.

<asp:UpdatePanel ID=”UpdatePanel1″

runat=”server”

UpdateMode=”Always”>

<ContentTemplate>

<asp:Timer ID=”Timer1″ runat=”server” Interval=”1000″>

</asp:Timer>

<asp:Label ID=”Label1″ runat=”server”

Height=”101px” style=”width:304px”>

</asp:Label>

</ContentTemplate>

</asp:UpdatePanel>

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

Operator in SQL

Posted on Updated on

What is an Operator in SQL?

An operator is a reserved word or a character used primarily in an SQL statement’s WHERE clause to perform operation(s), such as comparisons and arithmetic operations.

Operators are used to specify conditions in an SQL statement and to serve as conjunctions for multiple conditions in a statement.

· Arithmetic operators

· Comparison operators

· Logical operators

· Operators used to negate conditions

SQL Arithmetic Operators:

Assume variable a holds 10 and variable b holds 20, then:

Operator

Description

Example

+

Addition – Adds values on either side of the operator

a + b will give 30

Subtraction – Subtracts right hand operand from left hand operand

a – b will give -10

*

Multiplication – Multiplies values on either side of the operator

a * b will give 200

/

Division – Divides left hand operand by right hand operand

b / a will give 2

%

Modulus – Divides left hand operand by right hand operand and returns remainder

b % a will give 0

SQL Comparison Operators:

Assume variable a holds 10 and variable b holds 20, then:

Operator

Description

Example

=

Checks if the values of two operands are equal or not, if yes then condition becomes true.

(a = b) is not true.

!=

Checks if the values of two operands are equal or not, if values are not equal then condition becomes true.

(a != b) is true.

<>

Checks if the values of two operands are equal or not, if values are not equal then condition becomes true.

(a <> b) is true.

>

Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.

(a > b) is not true.

<

Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true.

(a < b) is true.

>=

Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true.

(a >= b) is not true.

<=

Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true.

(a <= b) is true.

!<

Checks if the value of left operand is not less than the value of right operand, if yes then condition becomes true.

(a !< b) is false.

!>

Checks if the value of left operand is not greater than the value of right operand, if yes then condition becomes true.

(a !> b) is true.

SQL Logical Operators:

Here is a list of all the logical operators available in SQL.

Show Examples

Ads by InfoAd Options

Operator

Description

ALL

The ALL operator is used to compare a value to all values in another value set.

AND

The AND operator allows the existence of multiple conditions in an SQL statement’s WHERE clause.

ANY

The ANY operator is used to compare a value to any applicable value in the list according to the condition.

BETWEEN

The BETWEEN operator is used to search for values that are within a set of values, given the minimum value and the maximum value.

EXISTS

The EXISTS operator is used to search for the presence of a row in a specified table that meets certain criteria.

IN

The IN operator is used to compare a value to a list of literal values that have been specified.

LIKE

The LIKE operator is used to compare a value to similar values using wildcard operators.

NOT

The NOT operator reverses the meaning of the logical operator with which it is used. Eg: NOT EXISTS, NOT BETWEEN, NOT IN, etc. This is a negate operator.

OR

The OR operator is used to combine multiple conditions in an SQL statement’s WHERE clause.

IS NULL

The NULL operator is used to compare a value with a NULL value.

UNIQUE

The UNIQUE operator searches every row of a specified table for uniqueness (no duplicates).

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com

DATA WAREHOUSING (introduction)

Posted on Updated on

INTRODUCTION TO DATA WAREHOUSING

A data warehouse is a repository of an organization’s electronically stored data. Data warehouses are designed to facilitate reporting and analysis.

A data warehouse is a powerful database model that significantly enhances the user’s ability to quickly analyze large, multidimensional data sets.

It cleanses and organizes data to allow users to make business decisions based on facts.

Hence, the data in the data warehouse must have strong analytical characteristics creating data to be analytical requires that it be –subject- oriented, integrated, time – referenced and non – volatile.

SUBJECT- ORIENTED DATA
This means a data warehouse has a defined scope and it only stores data under that scope. So for example, if the sales team of your company is creating a data warehouse – the data warehouse by definition is required to contain data related to sales.

Data Warehouses group data by subject rather by activity. In contrast, transactional systems are organized around activities – payroll processing, shipping products, loan processing, and the like.

Data organized around activities cannot answer questions such as, “how many salaried employees have a tax deductions of ‘X’ amount across all branches of the company?’’ this request would require have searching and aggregation of employee and account records of all the branches.

Imagine the query response time for a company having branches all over the country with employee strength of 20,000!

In a data warehouse environment, information’s used for analysis is organized around subjects- employees, accounts sales, products, and so on. This subject specific design helps in reducing the query response time by searching through very few records to get an answer to the user’s question.

INTEGRATED DATA

Integrated data refers to de – duplicating information and merging it from many sources into one consistent location.

When short listing your top 20 customers, you must know that ‘’HAL’’ and ‘’Hindustan aeronautics limited’’ are one and the same. There must be just one customer number for any form of HAL or Hindustan aeronautics limited, in your database.

This means that the data stored in a data warehouse make sense. Fact and figures are related to each other and they are integrable and project a single point of truth.

Much of the transformation and loading work that foes into the data warehouse is centered on integrating data and standardizing it,

TIME – REFERENCED DATA

The most important and most scrutinized characteristic of the analytical data is its prior state of bing. In other words, time-referenced data essentially refers to its time – valued characteristic. For example, the user may ask ‘’what were the total sales of product ‘A’ for the past three years on New Year’s Day across region ‘Y’?’’ to answer this question, you need to know the sales figures of the product on new year’s day in all the branches for that particular region.

This means that data is not constant, as new and new data gets loaded in the warehouse, data warehouse also grows in size

Time – referenced data when analyzed can also help in spotting the hidden treads between different associative data elements, which may not be obvious to the naked eye. This exploration activity is termed ‘’data mining’’.

NON – VOLATILE DATA

Since the information in a data warehouse is heavily queried against time, it is extremely important to preserve it pertaining to each and every business event of the company. The non – volatility of data, characteristic of data warehouse, enables users to dig deep into history and arrive at specific business decisions based on facts.

This means that data once stored in the data warehouse are not removed or deleted from it and always stay there no matter what.

NECESSITY –THE DATA ACCESS CRISIS

If there is a single key to survival in the 1990s and beyond, it is being able to analyze, plan, and react to changing business conditions in a much more repaid fashion. In order to do this, to managers, analysts, and knowledge workers in our enterprises, need more and better information.

Information technology (IT) has made possible the revolution in the way organizations operate throughout the world today. But the sad truth is, in many organizations, despite the availability of powerful computers on each desk and communication that span the globe, large numbers of executives and decision – makers cannot get their hands on exiting critical information in the organization.

Every day, organizations large and small, create billions of bytes of data about all aspects of their business; millions of individual facts about their customers, products, operations and people. But for the most part, this is locked up in a maze of computer systems and is exceedingly difficult to get at. This phenomenon has been described as “data in jail”.

Industry experts have estimated that only a small fraction of the data that is captured, processed and stored in the enterprise, is actually available to executives and decision makers. While technologies for the manipulation and presentations of data have literally exploded, it is only recently that those involved in developing IT strategies for large enterprise have concluded that large segments of the enterprise are “data poor”.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: http://www.vissicomp.com