Friday, November 25, 2011

Editor in Oracle Developer 2000/d2k/forms

Oracle forms/Oracle Reports/Oracle /Oracle D2k/Oracle 2000 /Oracle 10G
Editor :- (Cnt+e)

1. this is used to show an editor user to enter information in a more comfortable way, used for fields like, address, comments, name etc
2. there are 3 type of editor
• default editor
• system defined editor
• user defined editor


DEFAULT EDITOR :- every text box is by default associated with a default editor

SYSTEM EDITOR :- in the property of text item we can use ‘system editor’ to show system editor at run time.
( who notepad/textpat/wordpad depending on what is editor that is associated with oracle in the file init.ora)

User defined editor :-

1. we can create our own editor and show it to user as per our requirement using a built in procedure i.e show_editor

Syntax

Show editor (‘name of editor’,message_in,x_pos,y-pos,message_out,Boolean_val,out parameter);

Out parameter will return true if user clicked ok on editor and false if user cancelled the
Editor.

Various ways to used editor at run time.

1. on the text itme.
2. edit menu :- edit on the text item.
3. Built in procedure:- ‘edit –texttem’ in the triggers
4. show_editor

Steps for create an editor.
1. create an editor
2. Make changes in the property of editor as per requirement.
3. Show editor using show editor/others ways at run time.





Code for editor button (when-button-pressed) of job field of emp block :-

Declare
B Boolean;
V_job varchar2(4000);
Begin
Show_editor
(‘ed_job’,:emp.job,100,100,v_job,b);
If b then
If length(v_job)>9 then
Message(‘you can enter 9 letter only’);
Message(‘’);
Raise form_trigger_failure;
Else
:emp.job := v_job;
End if;
Else
Message(‘cancelled’);
Message(‘’);
End if ;
End;

Trigger in Oracle 10g

Trigger in Pl-sql/oracle/Oracle 10g forms and reports

1. it is a db object which is a collection of pl/sql codes and it automatically get executed whenever any dml event happens provided trigger has been written for that DML event.
2. Trigger has three section i.e. events, restrictions and when condition (optional.
3. Pl sql trigger is divided into two parts. 1. Row level 2. Statement level.


Row Level Statement Trigger.
1. Row level trigger is executed for each and every row affected by DML stmt.
2. we need to use for each row for row level trigger.
3. used in those cases where we need to depend on the values of every record of any column of any table.
4. eg. Any name begin inserted must be in letter capital.

Statement Level Trigger.

1. Statement level trigger is executed only once irrespective of No. of records affected by the dml statement.
2. Every trigger is by default STMT level trigger.
3. Used for restrictions like No Deletion allowed on Sunday on emp table.

Syntax.

CREATE [ OR REPLACE]
TRIGGER

BEFORE | AFTER
INSERT [ OR DELETE]
OF (OPTIONAL)
ON FOR EACH ROW (OPTIONAL) REFRENCING NEW AS OLD AS WHEN () (OPTIONAL) Note. 1. to follow any value of any col. Of any record of any table within the execution section of a trigger always used :old.and :new.2. Theses two can be followed only with in a row level trigger. :new. Refers to new values or that col for that row (Applicable for updated and insert) :old.Refers to old values for that col for that record (Applicable for both delete and update) Example:- Create or replace Trigger tr_ex Before delete On insert or update On emp For each row Declare V_msg varchar2(200) Begin If inserting then V_msg := ‘inserting….’ Elsif deleting then V_msg := ‘deleting………….’; Elsif updating then V_msg := ‘deleting…’; End if; Dbms_output.put_line(V_msg); End; Q. Create a trigger which will automatic make the first letter of every name inserted | updated into capital letter irrespective of any case enter by user. Create or replace trigger Tr_name Before update or insert Of ename On emp For each row Begin Dbms_output.put_line(‘before change name = ‘ ||.new.ename); End; / Example of Statement level trigger. CREATE OR REPLACE TRIGGER TR_DELETE BEFORE DELTE ON EMP BEGIN IF TRIM(TO_CHAR(SYSDATE,’DAY’)) = ‘SUNDAY’ THEN RAISE _APPLICATION_ERROR ( -20001,’NO DELTETION ALLOW ON SUNDAY); END IF; END; INSTEAD OF TRIGGER. This is used to perform DML operation on base table through join view. Create or replace trigger tr_instead Instead of Insert or update or delete On v_join Referencing new as N old as O For each row Declare V_count number; Begin If inserting then Select count(*) into v_count from dept Where deptno = :n.deptno; If v_count = 0 then Insert into dept values(:n.deptno,:n.dname,:n.loc); End if; Insert into emp (empno,ename,sal) values (:n.empno,:n.ename,:n.sal); Elsif updating then Update emp Set sal = :n.sal where empno = :o.empno; Update dept Set dname = :n.dname where deptno = :o.deptno; Elsif deleting then Delete from emp where empno = :o.empno; Delete from dept where deptno = :o.deptno; End if; End; /

Alert in Oracle D2k

Alert :-

1. This is used to display message to the user to confirm any action.
2. use show_alert to show the alert at run time.
3. the above function returns the following values (number()
88 alert_button1
89 alert_button2
90 alert_button3
4. u can change the following attribute of an alert at run time
(title,message,label of button)

Steps for creating a alert.
1. create an alert in object navigator through + command
2. make changed in the property of alert as per requirement.
3. now show the alert at run time using show_alert.


Code for ‘Key-delrec’ trigger at form level ( name of alert is alert_confirm)

Declare
Alt_ret_val numbers;
Begin
Set_alert_property ( ‘alert_confirm’, TITLE,’Confirming Delete Action’);
Set_alert_property ( ‘alert_confirm’,Alert_message_text,’Sure to delete this record ?? ‘);
Set_alert_button_property(‘alert_confirm’,alert_button,label,’plz delete’);
Alert_ret_val := show_alert(‘alert_confirm’);
If alert_ret_val := alert_button1 then delete_record;
Else
Message(‘you cance the operation’);
Message(‘’);
End if;
End;

Note :-
Max you can have 3 button and min you can have 1 button in an alert.
You can not change no of button at run time.

Code for delte record button is

Do_key(‘delete_record’);

It will make a call to key dec-rec

Trigger in D2kTrigger in D2kTrigger in D2k

Trigger in D2k

1. Trigger in form builder are available at three level ie item level, Block level and form level.
2. The area of application of trigger is dependent on the level where it has been defined.
3. If the same trigger has been defined at more than one level than the execution of trigger depends on the value of the property of trigger i.e. ‘ execution hierarchy’.
Override
1. It will override the entire higher level trigger having same name.
before
1. Lower level will be executed before its immediate parent level
After
1. lower level trigger will be executed after its immediate parent.

The lower level trigger will be always available but reverse is not true.



you can help for more these two pic following link








Trigger in form builder is divided into five parts.

1. Pre
2. post
3. when
4. on
5. key

Pre – Trigger. This trigger is executed before the current event.
Some of the pre trigger event are
1. pre-commit
2. pre-form
3. pre-logon
4. pre-text-item
5. pre-block

Pre-Query:-
1. This trigger is executed before any query is send to the database for execution.
2. it is used to validate the user input before sending the user-input to db to remove unnecessary presence on DB.

Code for Pre Query.


If :emp.deptno not in (10,20,30) then message (:emp.deptno ’ does not exict’);
Message(‘’);
Raise form_trigger_failure;
Length(:emp.empno) <4>







Post – trigger :->
1. These trigger are executed after the corresponding event.
2. some of the post trigger
• post-logon
• post-block
• post-query
• post-insert/update/delete
• post-text-item

Post-query:- this trigger is executed after the execution of query in the block
3. pre-query is executed only once and post-query is executed that many no. of times records returned by the query submitted to DB.


Code for Post –Query Emp block

Declare
V_groeg_sal number;
V_grade char(1);
Begin
V_groeg_sal := :emp.T_gross_sal;
If v_gross_sal >= 50000 and v_gross_sal <= 7000 then v_grade := ‘a’; Else v_gross_sal >= 3000 and v_gross_sal <>
1. this is executed one the cursor/control goes from the item.
2. use this trigger to populate any value like grade on the basis of gross sal(sal + comm.)


When trigger ->

1. These trigger get executed when the corresponding event happens.
2. some of the when –trigger
when –button-pressed
when-validate-item
when-validate-record
when-new-item-instance
when-new-record-instance
when-new-block-instance
when-create-record


when-validate-item :-

it is executed when the control comes out of any item after making changes in th e value that item.


When-validate-record :- executed when the control goes out of the current record after making changes in the record.

When –create-record

This trigger is executed when a new record is created in the block.
This is the only trigger in form builder when the forms does not ask you to save changes if we have allocated some value to my field of the block.

Code for when –create-record at emp block

:emp.sal := 200;
:emp.comm := 100;

Code for when-validate-item of Sal field
If :emp.sal<2000> 2000’);
Raise form_trigger_failure;
End if;

Code at blk level
When-validate-record of emp block

If :emp.sal<:emp.comm Then Message(‘plz enter sal>comm’);
Message(‘’);
Raise form_trigger_failure;
Else if :emp.name is null or length(:emp.ename)<4> these trigger executed during corresponding event.

Some of the trigger are.

On-error
On-message
On-logon
On-insertupdatedelete

On-error:-> in this trigger is executed when any errors happens at run time which is a system defined error.
Some of the keyword are

Error-code
Error-type
Error-text

On-message

This is executed when any message comes at run time from form builder.

Keywords

Message-code
Message-type
Message-text
Code for on-error at form level

If error_code = 50016
Then message(‘plz enter only number’);
Message(‘’);
Else
Message(Error_code - ‘ error_type ’ ‘ error_text);
Message(‘’)


Key trigger :-> these trigger are executed whenever a corr. Runtime key is used

Key Trigger Bultin
F7 Key-enter Enter_query
F8 Key-executed Execute_query
F9 Key-listval List-values
F10 Key-commit Commit
F6 Key-crerec Create_record
Shift+f6 Key-delrec Delete_record

1. we can use key trigger to override the default functionality of run time keys.
2. we can use do_key (‘buil-in’) to call the corr/key trigger.
3. for example do_key(‘commit’) will made a call to key-commit trigger.
4. we can also use execute-trigger (‘any trigger name’) to execute the code of any trigger

execute_trigger(‘key-nxtrec’);

Code :-> for key-nexrec

If :system.last_record = ‘true’ then
Message (‘ you are already at last record’);
Message(‘’);
Raise form_trigger_failure;
Else
Next_record;
End if;

Code for next_record button

Button
D0-key(‘next_record’);
Execute_trigger(‘key-nxtrec’);



Code for key-up

If :system.cursor_record = ‘1’
Then message(‘ you are already at first record’);
Message(‘’);
Raise form_trigger_failure;
Else
Previous_record;
End if;

Oracle Develper 2000/D2k/10g Basics tutorial

Form Builder

1. Minimum component required to develop a module is
• Window
• Canvas
• Block
• Item
Window:- this forms object is used to provide physical support to canvas.
Canvas :- this is used to provide physical support to item.
Item:- this is used to accept value from user at run time.
Some of the GUI item are Text Box, Button, Radio Button, Check Box

Block:-
• This is a collection of item and it does not any physical significance. Block always have logically significance.
• There are two type of block DB block and control block

Imp Point.
1 to follow the value of any item of any block use
:.
2. to refer to any item of block , user block name.itemname/
3. to take cursor to any item at run time user go_item(‘blockname.item.name’);
4. to clear block user clear_block;


some of the system defined built ins are.
1. go_item(‘item name’);
2. go_block(‘block name’);
3. go_record(‘sr.no.of.record’);
4. next_item
5. next_block
6. next_record;
7. previous_item
8. previous_block
9. previous_record
10. clear_block
11. clear_item
12. clear_record
13. clear_form
14. execute_query
15. last_record

Object Navigator has two view i.e

1. Ownership view :-
It show the relationship between block and item.
2. physical view :-
it shows the relation between window, canvass and item.
Items are linked to a canvas through its properties.
Canvas is linked to window through properties.

Base table Block

1. This block is associated with a DB object like table,view,procedure.
2. based table block can be created in two ways i.e through wizard, and through manually

Through the wizard.
1. Create a block through object navigator.
2. Select wizard from dialog box.
3. Keep on clicking on next button till the time you get finish button.
4. Save, compile and run the report.

Note
1. use the runtime menu option and toolbar option to do DML operation on a base table block.
2. Some of imp. Menu option are query menu, record menu, block menu.


Cd
code for + button when-button-pressed
:ankur.result := :ankur.result_no1 + :ankur:result_no_2;

Code for – button when button pressed

:ankur.result := :ankur.result_no1 - :ankur:result_no_2;

Code for * button when button pressed

:ankur.result := :ankur.result_no1 * :ankur:result_no_2;

Code for / button when button pressed

:ankur.result := :ankur.result_no1 / :ankur:result_no_2;

How to create a base table block manually

1. crate a block
2. select the option manual from the new block dialog box and say ok
3. in the layout editor, place the items in the block by selecting the block name from list box for block on top right of canvas.
4. in the property of block mention , Name, Datasource type(table), insert/update/delete/query/allowing (yes/no),
5. Now in the property of items mention Name,Data type, Size Colum name,

Control block

1. this is not associated with any DB object
It is used for following purposes (Calculator, Button to do some action.)

Crate a Control block.
1. create a block.
2. in the prop of block (named blocks (no))
3. place items in the block and make required changed in the property of items
Some of the builtin are

Enter_query;
Execute_query;
Create_Record;
Delete_record;
Commit;
Exit_form
First/last/next/pervious-record;

Saturday, September 17, 2011

JDBC

->What are the steps involved in establishing a JDBC connection?
This action involves two steps: loading the JDBC driver and making the connection.


->How can you load the drivers?
Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it:

Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”);

Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ, you would load the driver with the following line of code:

Class.forName(”jdbc.DriverXYZ”);

->What will Class.forName do while loading drivers?
It is used to create an instance of a driver and register it with the
DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.

->How can you make the connection?
To establish a connection you need to have the appropriate driver connect to the DBMS.
The following line of code illustrates the general idea:

String url = “jdbc:odbc:Fred”;
Connection con = DriverManager.getConnection(url, “Fernanda”, “J8?);

->What are the different types of Statements?
Regular statement (use createStatement method), prepared statement (use prepareStatement method) and callable statement (use prepareCall)


->What is Statement ?
Statement acts like a vehicle through which SQL commands can be sent. Through the connection object we create statement kind of objects.
Through the connection object we create statement kind of objects.

Statement stmt = con.createStatement();

This method returns object which implements statement interface.

->What is PreparedStatement?
A prepared statement is an SQL statement that is precompiled by the database. Through precompilation, prepared statements improve the performance of SQL commands that are executed multiple times (given that the database supports prepared statements). Once compiled, prepared statements can be customized prior to each execution by altering predefined SQL parameters

PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?");
pstmt.setBigDecimal(1, 153833.00);
pstmt.setInt(2, 110592);


->What are callable statements ?
Callable statements are used from JDBC application to invoke stored procedures and functions.
CallableStatement stproc_stmt = conn.prepareCall("{call procname(?,?,?)}");

->How can you retrieve data from the ResultSet?
JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to hold our results. The following code demonstrates declaring the ResultSet object rs.

ResultSet rs = stmt.executeQuery(”SELECT COF_NAME, PRICE FROM COFFEES”);



->What are types of JDBC drivers?
There are four types of drivers defined by JDBC as follows:

Type 1: JDBC/ODBC—These require an ODBC (Open Database Connectivity) driver for the database to be installed. This type of driver works by translating the submitted queries into equivalent ODBC queries and forwards them via native API calls directly to the ODBC driver. It provides no host redirection capability.

Type2: Native API (partly-Java driver)—This type of driver uses a vendor-specific driver or database API to interact with the database. An example of such an API is Oracle OCI (Oracle Call Interface). It also provides no host redirection.

Type 3: Open Protocol-Net—This is not vendor specific and works by forwarding database requests to a remote database source using a net server component. How the net server component accesses the database is transparent to the client. The client driver communicates with the net server using a database-independent protocol and the net server translates this protocol into database calls. This type of driver can access any database.

Type 4: Proprietary Protocol-Net(pure Java driver)—This has a same configuration as a type 3 driver but uses a wire protocol specific to a particular vendor and hence can access only that vendor's database. Again this is all transparent to the client.
Note: Type 4 JDBC driver is most preferred kind of approach in JDBC.

->What are the main components of JDBC ?
The life cycle of a servlet consists of the following phases:

DriverManager: Manages a list of database drivers. Matches connection requests from the java application with the proper database driver using communication subprotocol. The first driver that recognizes a certain subprotocol under JDBC will be used to establish a database Connection.

Driver: The database communications link, handling all communication with the database. Normally, once the driver is loaded, the developer need not call it explicitly.

Connection : Interface with all methods for contacting a database.The connection object represents communication context, i.e., all communication with database is through connection object only.

Statement : Encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed.

ResultSet: The ResultSet represents set of rows retrieved due to query execution.


->What is JDBC Driver interface?
The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendor driver must provide implementations of the java.sql.Connection,Statement,PreparedStatement, CallableStatement, ResultSet and Driver.

Thursday, September 15, 2011

Replace a line or word in a file

Replace a line or word in a file

import java.io.*;

public class BTest
{
public static void main(String args[])
{
try
{
File file = new File("file.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
String line = "", oldtext = "";
while((line = reader.readLine()) != null)
{
oldtext += line + "\r\n";
}
reader.close();
// replace a word in a file
//String newtext = oldtext.replaceAll("drink", "Love");

//To replace a line in a file
String newtext = oldtext.replaceAll("This is test string 20000", "blah blah blah");

FileWriter writer = new FileWriter("file.txt");
writer.write(newtext);writer.close();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}

file.txt
I drink Java
I sleep Java
This is test string 1
This is test string 20000

Thursday, August 25, 2011

Transfer huge files using web browser

1. How to transfer huge files online (through web browser) without registering and without installing any s/w?

The following sites do the task.



www.filesovermiles.com

http://jetbytes.com

www.pipebytes.com/



www.dushare.com

www.yousendit.com



PFA for more info.



2. How to share/transfer files within the same LAN if "Sharing" is disabled by your admin?



http://www.ezyfiletransfer.com/


It needs Java to be installed in your machine.

Wednesday, July 27, 2011

Selection Sort in C

#include
int main()
{
int i,j,num,list[6],temp;


printf("Enter the Numbers:");
for(i=0;i<6;i++)
{
scanf("%d",&list[i]);
}
printf("Entered Numbers are:");
for(i=0;i<6;i++)
{
printf("%d ",list[i]);
}
for(i=0;i<6;i++)
{
for(j=0;j<5;j++)
{
if(list[j]>list[i])//if u put > as < u will get descending order
{
temp=list[i];
list[i]=list[j];
list[j]=temp;
}


}

}
printf("\nascending order\n");
for(j=0;j<6;j++)
{
printf("%d ",list[j]);
}
printf("\n");
}

Tuesday, July 26, 2011

Linear Search in C

#include
int main()
{
int i,item,list[5];
printf("Enter numbers;\n");
for(i=0;i<5;i++)
{
scanf("%d",&list[i]);
}
printf("Entered Numbers Are:\n");
for(i=0;i<5;i++)
{
printf("%d ",list[i]);
}
printf("Enter item to be selected:\n");
scanf("%d",&item);
for(i=0;i<5;i++)
{
if(item==list[i])
{
printf("item found at postion:%d\n",i+1);
printf("founded item is:%d\n",list[i]);
return;
}
}
printf("item does not exist\n");
}

bubble sort in c

#include
int main()
{
int i,j,num,list[6],temp;


printf("Enter the Numbers:");
for(i=0;i<6;i++)
{
scanf("%d",&list[i]);
}
printf("Entered Numbers are:");
for(i=0;i<6;i++)
{
printf("%d ",list[i]);
}
for(i=0;i<6;i++)
{
for(j=0;j<5;j++)
{
if(list[j]>list[j+1])
//if u change > as < you will get Descending order
{
temp=list[j];
list[j]=list[j+1];
list[j+1]=temp;
}


}

}
printf("\nascending order\n");
for(j=0;j<6;j++)
{
printf("%d ",list[j]);
}
printf("\n");
}

Binary Search in C

#include
void binary()
{
int i,item,mid;
int list[6];
printf("Enter the values:");
for(i=0;i<5;i++)
{
scanf("%d",&list[i]);
}
printf("Entered Items are:");
for(i=0;i<5;i++)
{
printf("%d ",list[i]);
}
printf("\n");
//int list[5]={1,2,3,4,5};
int lower,upper;
lower=0;
upper=4;
printf("item to be searched:");
scanf("%d",&item);
while(1)
{
mid=(lower+upper)/2;
if(list[mid]==item)
{
printf("position of item is:");
printf("%d",mid+1);
return;
}
else if(list[mid] {
lower=mid+1;
}
else
{
upper=mid-1;
}
if(lower>upper)
{
printf("item does not exist:");
return;
}


}



}
int main()
{
binary();
}

Stack in DataStructure

#include
#include
#include
int top=-1,count=0;
char stk[10][10];
void push();
void pop();
void display();
int main()
{
int ch;
do{
printf("\n1.Push\n2.pop\n3.Display\n4.Exit\n");
printf("Enter u r choice:\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
exit(0);
default:
printf("Enter Correct vale\n");

}
}while(ch!=4);

}
void push()
{
char name[10];
if(top<10)
{
printf("Enter any string:\n");
top++;
count++;
scanf("%s",name);
strcpy(stk[top],name);

}
else
{
printf("stack is full\n");
return;
}

}
void pop()
{
if(top==-1)
{
printf("stack is empty:\n");
}
printf("Elements deletd:%s ",stk[top]);
top--;
count--;


}
void display()
{
int i;
if(top==-1)
{
printf("stack is empty:\n");
}
printf("Items on the stack:\n");
for(i=0;i<=top;i++)
{
printf("%s ",stk[i]);
}
}

Single Linked List in DataStructure

#include
#include
#include
struct list
{

int data;
struct list *next;
}*root = NULL;
int count = 0;
void create()
{
int item;
struct list *temp,*node;
temp=(struct list *)malloc(sizeof(struct list));
printf("Enter Value :\n");
scanf("%d",&item);
temp->data = item;
if(root == NULL)
{
root = temp;
root->next = NULL;
count++;
return;
}
node = root;
while(node->next != NULL)
{
node = node->next;
}
node->next = temp;
temp->next = NULL;
count++;

}
void display()
{
struct list *temp;
temp = root;
if(root == NULL)
{
printf("list is empty\n");
return;
}
while(temp!=NULL)
{
printf("\t%d ",temp->data);
temp= temp->next;
}
printf("\n");

}
void insertatbeg()
{
struct list *temp;
temp = (struct list *)malloc(sizeof(struct list));
printf("Enter Value : \n");
scanf("%d",&temp->data);
if(root == NULL)
{
root = temp;
temp->next =NULL;
return;
}
temp->next = root;

root = temp;
count++;
}
void insertatmid()
{
struct list *temp,*node;
int pos,i=0;
temp= (struct list *)malloc(sizeof(struct list));
printf("Enter value: \n");
scanf("%d",&temp->data);
if(root==NULL)
{
printf("list is Empty");
return;
}
node=root;
printf("Enter the position to enter node:");
scanf("%d",&pos);
if(pos>count || pos<0)

{
printf("Enter correct position:\n");

}
while(i<=count)
{
if(i==pos-1)
{
temp->next=node->next;

node->next=temp;

count++;
return;

}
node=node->next;
i++;
}
}
void insertlast()
{
struct list *temp,*node;
temp=(struct list *)malloc(sizeof(struct list));
printf("Enter Value:\n");
scanf("%d",&temp->data);
if(root==NULL)
{
printf("list is empty:\n");
}
node=root;
while(root!=NULL)
{
if(node->next==NULL)
{
node->next=temp;
temp->next=NULL;
count++;
return;
}
else
{
node=node->next;
}
}



}
void deleteatbeg()
{
if(root==NULL)
{
printf("List is Empty");
}
printf("deleted value:%d",root->data);
root=root->next;

count--;
}
void deleteatmid()
{
struct list *temp,*node;
int pos,i=0;

if(root==NULL)
{
printf("list is Empty");
return;
}
node=root;
printf("Enter the position to delete node:");
scanf("%d",&pos);
if(pos>count || pos<0)
{
printf("Enter correct position:\n");

}
while(i<=count)
{
if(i==pos-1)
{

temp=node->next->next;
node->next=temp;

count--;
return;

}
node=node->next;
i++;
}

}
void deletelast()
{
struct list *temp,*node;

if(root==NULL)
{
printf("List is empty:");
return;
}
temp=root;
if(root->next==NULL)
{
printf("deleted item is:%d",node->data);
root=NULL;
return;
}

while(temp->next->next!=NULL)
{
temp=temp->next;

}
printf("deleted data is:%d",temp->next->data);
temp->next=NULL;




}
int main()
{
int ch;
do{
printf("\n1.insert\t2.delete\t3.Display\t4.Exit\t5.insertatbeg\t6.deleteatbeg\t7.insertatmid\t8.deleteatmid\t9.insertlast\t10.deletelast\n");
printf("Enter u r choice:\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
create();
break;
case 2:
//delete();
break;
case 3:
display();
break;
case 4:
exit(0);
case 5:
insertatbeg();
break;
case 6:
deleteatbeg();
break;
case 7:
insertatmid();
break;
case 8:
deleteatmid();
break;
case 9:
insertlast();
break;
case 10:
deletelast();
break;

default:
printf("Enter Correct vale\n");

}
}while(ch!=4);



}

Sunday, July 10, 2011

write a program to convert decimal to binary,octal and decimal?


Answer:

#include
void main()
{
int d;
int i=0,n,j,b[100];
cout<<"\n Press 1 for Decimal to Binary converstion";
cout<<"\n press 2 for Decimal to Octal converstion ";
cout<<"\n press 3 for Decimal to Hexadecimal converstion";
cout<<"\n\nEnter your choice: ";
cin>>d;
switch(d)
{
case 1:
cout<<"\nEnter decimal number: ";
cin>>n;
while (n>0)
{
b[i]=n%2;
n=n/2;
i++;
}
cout<<"\nBinary is: ";
j=i-1;
for (i=j;j>=0;j--)
{
cout<}
break;
case 2:
cout<<"\nEnter decimal number: ";
cin>>n;
while (n>0)
{
b[i]=n%8;
n=n/8;
i++;
}
cout<<"\nOctal is: ";
j=i-1;
for (i=j;j>=0;j--)
{
cout<}

break;
case 3:
cout<<"\nEnter decimal number: ";
cin>>n;
while (n>0)
{
b[i]=n%16;
n=n/16;
i++;
}
cout<<"\nHexadecimal is:";
j=i-1;
for (i=j;j>=0;j--)
{
cout<if(b[j]<10)
{
cout<}
else
{
switch(b[j])
{
case 10:
cout<<"A";
break;
case 11:
cout<<"B";
break;
case 12:
cout<<"C";
break;
case 13:
cout<<"D";
break;
case 14:
cout<<"E";
break;
case 15:
cout<<"F";
break;
}
}
}

}

Thursday, April 28, 2011

Best place to practice Logical Reasoning

Number Series Letter and Symbol Series Verbal Classification
Essential Part Analogies Artificial Language
Matching Definitions Making Judgments Verbal Reasoning
Logical Problems Logical Games Analyzing Argumentshttp://www.blogger.com/img/blank.gif
Statement and Assumption Course of Action Statement and Conclusion
Theme Detection Cause and Effect Statement and Argument
Logical Deduction

Link:http://www.indiabix.com/logical-reasoning/questions-and-answers/

Link2:http://www.indiabix.com/

Tuesday, April 26, 2011

Best Site for English Grammer

English grammar rules explained, together with examples.

Lists of English tenses - past simple, present perfect, future perfect, etc.
http://www.blogger.com/img/blank.gif
Structures of the tenses, plus examples.

Examples of common errors and explanations of how you can avoid making such mistakes.

Use the navigation on the left to choose the grammar point you want to study. This page is for students and teachers

Link:http://speakspeak.com/a/html/d10_english_grammar.htm

Saturday, April 23, 2011

SQL for Beginners

SQL Commands:

SQL commands are instructions used to communicate with the database to perform specific task that work with data. SQL commands can be used not only for searching the database but also to perform various other functions like, for example, you can create tables, add data to tables, or modify data, drop the table, set permissions for users. SQL commands are grouped into four major categories depending on their functionality:

Data Definition Language (DDL) - These SQL commands are used for creating, http://www.blogger.com/img/blank.gifmodifying, and dropping the structure of database objects. The commands are CREATE, ALTER, DROP, RENAME, and TRUNCATE.
Data Manipulation Language (DML) - These SQL commands are used for storing, retrieving, modifying, and deleting data. These commands are SELECT, INSERT, UPDATE, and DELETE.
Transaction Control Language (TCL) - These SQL commands are used for managing changes affecting the data. These commands are COMMIT, ROLLBACK, and SAVEPOINT.
Data Control Language (DCL) - These SQL commands are used for providing security to database objects. These commands are GRANT and REVOKE.


Link : http://beginner-sql-tutorial.com/sql-commands.htm

Search This Blog