Saturday, September 25, 2010

how to enable template path hint in magento 1.4

If you want this option displayed for ‘default config’ also, just edit the app\code\core\Mage\Core\etc\system.xml file.
Look for something like this
<template_hints translate="label">
<
label>Template Path Hintslabel>
<
frontend_type>selectfrontend_type>
<
source_model>adminhtml/system_config_source_yesnosource_model>
<
sort_order>20sort_order>
<
show_in_default>0show_in_default>
<
show_in_website>1show_in_website>
<
show_in_store>1show_in_store>
template_hints>
replace
<show_in_default>0show_in_default>
with
<show_in_default>1show_in_default>
Do the same for this section
<template_hints_blocks translate="label">
<
label>Add Block Names to Hintslabel>
<
frontend_type>selectfrontend_type>
<
source_model>adminhtml/system_config_source_yesnosource_model>
<
sort_order>21sort_order>
<
show_in_default>0show_in_default>
<
show_in_website>1show_in_website>
<
show_in_store>1show_in_store>
template_hints_blocks>
and clear the cache

Resloving magento 1.4 fatal error:line 529

in page.xml under app/design/frontend/base/default/layout (or your custome page.xml)

change the line
to


and clear the cache

Wednesday, September 22, 2010

STRESS!!!! OH!

Before I proceed. I would like to ask you some personal questions, Like:

HOW ARE YOU??? ARE YOU TENSED???

HOW MANY TIME IN A DAY YOU ARE TAKING CARE OF YOUR HEALTH?

Though we are in 20th century, we all have liking for free and modern life style.This modern civilization changes the attitude of woman and makes her busy in her outside job as the house hold. She is now having her two legs in two running boats. Butt you better Know What will be the result. That leads to physical and mental tension.

Today’s work tension makes her not active but also reactive:

We all know about our great scientist Sir Issac Newton. According to his third law of motion-”every action there is an equal and opposite reaction”.

But it is required that this reaction should be positive. when it is concerned with our health. My intention is not to avoid you to do the job but simultaneously you should give importance to your health.

You know scientist are the most busiest person mentally they are not free.

some time this tensed mind caused unnatural death Like “Madam Curie.” Now I am giving You an Example Newton’s busiest life how his mind had no control over his body.

Sir Issac Newton was very absent minded, when he was thinking over a problem.

One morning he got up early and was thinking abut his reaserch problem so deeply that he would not leave the problem and go for the breakfast. but his house-keeper ‘Marry’ thught that newton needed food. So she took a pan of water and egg, and started boiled it.

but Newton wanted to be alone and said

“Marry you can leave the egg with me , I will boil it.”then Marry put the egg on table beside his watch and said Issac you must boiled the egg for Four minutes and went away.

But she was afraid that the Newton might forget to boil the egg. So she returned after an hour later. then you know what she find there?

She found that Newton was standing by the fireplace. He had put the watch in the sauce pan for boiling instead of egg, which was in his hand and still thinking about the problems.

learn from others ‘experience

man’s life in this world is comparatively a shorter one.therefore,he doesn’t have time to learn everything from personal experiences .here is the importance of drawing inspiration from others and their experiences.in other words ,don’t wait for a chance to make the entire mistakes yourself.learning from others’ experience will protect you from a number of failures.

we should also learn some lessons from the nature . the animals ,birds,mountains,plants and everything we see in the world teach us something .you might have heard about the story of Robert Bruce who got inspiration from a spider to defeat the enemies .we can learn a lot of things from the nature ,only if we have an open mind.

Monday, August 2, 2010

calculator program

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* TwoNumbers.java
*
* Created on Jul 19, 2010, 11:59:42 AM
*/

/**
*
* @author Achanta
*/
public class TwoNumbers extends javax.swing.JFrame {
private boolean counter = true,op=false;
String strnum;
int total = 0,i=0;
boolean click = true;
private int no = 0,lastCommand=1,command=0;
private boolean addClick=true,subClick=true,mulClick=true,divClick=true;
String temp;
int opType=0;
int opStack[]=new int[20];

/** Creates new form TwoNumbers */
public TwoNumbers() {
initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/

// //GEN-BEGIN:initComponents
private void initComponents() {

jButton11 = new javax.swing.JButton();
text = new javax.swing.JTextField();
add = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
sub = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
mulbutton = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
divbutton = new javax.swing.JButton();
equalbutton = new javax.swing.JButton();
c = new javax.swing.JButton();
backspace = new javax.swing.JButton();

jButton11.setText("jButton11");

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

add.setText("+");
add.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addActionPerformed(evt);
}
});

jButton1.setText("1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setText("2");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton3.setText("3");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

sub.setText("-");
sub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
subActionPerformed(evt);
}
});

jButton4.setText("4");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jButton5.setText("5");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});

jButton6.setText("6");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});

jButton7.setText("7");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});

jButton8.setText("8");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});

jButton9.setText("9");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});

jButton10.setText("0");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});

mulbutton.setText("*");
mulbutton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mulbuttonActionPerformed(evt);
}
});

jLabel1.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
jLabel1.setText("Calculator");

divbutton.setText("/");
divbutton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
divbuttonActionPerformed(evt);
}
});

equalbutton.setText("=");
equalbutton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
equalbuttonActionPerformed(evt);
}
});

c.setText("C");
c.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cActionPerformed(evt);
}
});

backspace.setText("BackSpace");
backspace.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backspaceActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton9))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton4)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton5)
.addComponent(jButton10)))
.addComponent(text, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(backspace, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(c, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(add)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(sub)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(mulbutton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(divbutton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(equalbutton))
.addGroup(layout.createSequentialGroup()
.addGap(86, 86, 86)
.addComponent(jLabel1)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(text, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4)
.addComponent(jButton5)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton6)
.addComponent(jButton7)
.addComponent(jButton8)
.addComponent(jButton9)
.addComponent(jButton10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(add)
.addComponent(sub, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE)
.addComponent(mulbutton)
.addComponent(divbutton)
.addComponent(equalbutton))
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(backspace)
.addComponent(c))
.addContainerGap())
);

pack();
}//
//GEN-END:initComponents
private void equal()
{
no=Integer.parseInt(text.getText());
switch(opType)
{
case 1:
total += no;
break;
case 2:
total -= no;
break;
case 3:
total *= no;
break;
case 4:
total /= no;
break;
}
text.setText(Integer.toString(total));
counter=true;
}
private void getDigits()
{
if(counter==true)
{
text.setText("");
text.setText(temp);
no=Integer.parseInt(temp);
counter=false;
}
else {
strnum=text.getText() + temp;
no=Integer.parseInt(strnum);
text.setText(strnum);
}
}

private void assign() {
if (op == false) {
getDigits();
} else {

opeartion();
}
}
private void opeartion() {
if (
(addClick == true || subClick == false||mulClick==false||divClick==false)&&
(subClick==true||addClick==false||mulClick==false||divClick==false)&&
(mulClick==true||addClick==false||subClick==false||divClick==false)&&
(divClick==true||addClick==false||subClick==false||mulClick==false))
{
total = Integer.parseInt(text.getText());
System.out.println("the total and no values are "+total+" "+no);

subClick = false;
mulClick = false;
divClick = false;
addClick = false;
}
else
{
switch (opType) {
case 1:System.out.println("the total and no values are "+total+" "+no);
total+= no;
break;
case 2:System.out.println("the total and no values are "+total+" "+no);
total-= no;
break;
case 3:System.out.println("the total and no values are "+total+" "+no);
total*=no;
break;
case 4:System.out.println("the total and no values are "+total+" "+no);
total=total/no;
break;
}
}
text.setText(Integer.toString(total));
counter=true;
}



private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed
op=true;
opType=1;subClick=true;mulClick=true;divClick=true;
assign();
}//GEN-LAST:event_addActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

temp = "1";op=false;
assign();

}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
temp = "2";op=false;
assign();



}//GEN-LAST:event_jButton2ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
temp = "3";op=false;
assign();


}//GEN-LAST:event_jButton3ActionPerformed

private void subActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subActionPerformed
op=true;
opType=2;addClick=true;mulClick=true;divClick=true;
assign();
}//GEN-LAST:event_subActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
temp = "4";op=false;
assign();
}//GEN-LAST:event_jButton4ActionPerformed

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
temp = "5";op=false;
assign();
}//GEN-LAST:event_jButton5ActionPerformed

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
temp = "6";op=false;
assign();
}//GEN-LAST:event_jButton6ActionPerformed

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
temp = "7";op=false;
assign();
}//GEN-LAST:event_jButton7ActionPerformed

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
temp = "8";op=false;
assign();
}//GEN-LAST:event_jButton8ActionPerformed

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
temp = "9";op=false;
assign();
}//GEN-LAST:event_jButton9ActionPerformed

private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
temp = "0";op=false;
assign();
}//GEN-LAST:event_jButton10ActionPerformed

private void mulbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mulbuttonActionPerformed
op=true;
opType=3;addClick=true;subClick=true;divClick=true;
assign();
}//GEN-LAST:event_mulbuttonActionPerformed

private void divbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_divbuttonActionPerformed
op=true;
opType=4;addClick=true;subClick=true;mulClick=true;
assign();
}//GEN-LAST:event_divbuttonActionPerformed

private void equalbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_equalbuttonActionPerformed
addClick=true;subClick=true;mulClick=true;divClick=true;
equal();
}//GEN-LAST:event_equalbuttonActionPerformed

private void cActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cActionPerformed
no=0;
text.setText("");
}//GEN-LAST:event_cActionPerformed

private void backspaceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backspaceActionPerformed
String notemp=Integer.toString(no);
System.out.println("the string length is "+notemp.length());
if (notemp.length() == 1) {
no = 0;
notemp=Integer.toString(no);
} else {
notemp = notemp.substring(0, notemp.length() - 1);
int no = Integer.parseInt(notemp);
System.out.println("the number is " + no);
}

text.setText(notemp);
counter=true;
}//GEN-LAST:event_backspaceActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TwoNumbers().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton add;
private javax.swing.JButton backspace;
private javax.swing.JButton c;
private javax.swing.JButton divbutton;
private javax.swing.JButton equalbutton;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JButton mulbutton;
private javax.swing.JButton sub;
private javax.swing.JTextField text;
// End of variables declaration//GEN-END:variables






}

Sunday, May 9, 2010

programs

Menu.java


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javaapplication1;

/**
*
* @author Sravanthi
*/
import java.util.*;
public class Menu
{
Scanner sc=new Scanner(System.in);
int no=0;
String name=null;
public Menu()
{}
public void mainmenu()
{
int mchoice=0;
System.out.println("***Main Menu***");
System.out.println("----------------");
System.out.println("1.Admin");
System.out.println("2.User");
System.out.print("enter your choice:");
mchoice=sc.nextInt();
switch(mchoice)
{
case 1:adminmenu();
break;
case 2:usermenu();
break;
}
}

public void adminmenu()
{
do
{
int achoice=0;

System.out.println("****Admin****");
System.out.println("--------------");
System.out.println("1.View");
System.out.println("2.Insert");
System.out.println("3.Update");
System.out.println("4.Delete");
System.out.println("5.Main menu");
System.out.println("6.Exit");
System.out.print("enter your choice:");
achoice=sc.nextInt();
switch(achoice)
{
case 1:
View.view();
break;
case 2:System.out.println("Enter the no:");
no=sc.nextInt();
System.out.println("Enter the name:");
name=sc.next();
Insert.insert(no,name);
break;
case 3:Update.update();
break;
case 4:Delete.delete();
break;
case 5:mainmenu();
break;
case 6:System.exit(0);
default:System.out.println("invalid choice");
}
}while(true);
}

public void usermenu()
{
do
{
int uchoice=0;

System.out.println("****Admin****");
System.out.println("--------------");
System.out.println("1.View");
System.out.println("2.Main menu");
System.out.println("3.Exit");
System.out.print("enter your choice:");
uchoice=sc.nextInt();
switch(uchoice)
{
case 1:View.view();
break;

case 2:mainmenu();
break;
case 3:System.exit(0);
default:System.out.println("invalid choice");
}
}while(true);
}

public static void main(String args[])
{
Menu m=new Menu();
m.mainmenu();
}
}





MySqlconnectin.java



/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javaapplication1;

/**
*
* @author Sravanthi
*/
import java.sql.*;
public class MysqlConnection
{
public static Connection getConnection()
{
Connection con=null;
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");

}
catch(ClassNotFoundException ce)
{
ce.printStackTrace();
}
catch(SQLException sq)
{
sq.printStackTrace();
}
return con;
}
}



insert.java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javaapplication1;

/**
*
* @author Sravanthi
*/
import java.sql.*;
public class Insert
{
public static void insert(int no,String name)
{
try
{
String sql = "insert into first values("+no+",'"+name+"') ";
Connection connection = MysqlConnection.getConnection();
Statement statement = connection.createStatement();
int n=statement.executeUpdate(sql);
if(n>0)
System.out.println("Record inserted successfully");
else
System.out.println("Record was not inserted");

}
catch(SQLException sq)
{
sq.printStackTrace();
}

}


}


Delete.java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javaapplication1;

/**
*
* @author Sravanthi
*/
import java.sql.*;
public class Delete
{
public static void delete()
{
try
{
String sql = "delete from first where id=1 ";
Connection connection = MysqlConnection.getConnection();
Statement statement = connection.createStatement();
int n=statement.executeUpdate(sql);
if(n>0)
System.out.println("Record was successfully deleted");
else
System.out.println("Record was not deleted");

}
catch(SQLException sq)
{
sq.printStackTrace();
}

}
public static void main(String args[])
{

Delete.delete();
}
}


update.java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javaapplication1;

/**
*
* @author Sravanthi
*/
import java.sql.*;
public class Update
{
public static void update()
{
try
{
String sql = "update first set id=121 where id=2 ";
Connection connection = MysqlConnection.getConnection();
Statement statement = connection.createStatement();
int n=statement.executeUpdate(sql);
if(n>0)
System.out.println("Record was successfully updated");
else
System.out.println("Record was not updated");

}
catch(SQLException sq)
{
sq.printStackTrace();
}

}
public static void main(String args[])
{

Update.update();
}
}


view.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javaapplication1;

/**
*
* @author Sravanthi
*/
import java.sql.*;
public class View
{
public static void view()
{
try
{
String sql = "select * from first ";
Connection connection = MysqlConnection.getConnection();
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(sql);
while(rs.next())
{
System.out.println(rs.getInt(1)+"\t"+rs.getString(2));
}
}
catch(SQLException sq)
{
sq.printStackTrace();
}

}


}

Friday, May 7, 2010

course program

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package preparetes;

/**
*
* @author admin
*/
import java.util.*;
import java.sql.*;
public class Course {
Scanner sc=new Scanner(System.in);
Connection con=null;
Statement st=null;
ResultSet rs=null;

public void connection()
{


try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/s","root","admin");
st=con.createStatement();
}
catch(Exception e)
{
e.printStackTrace();
}
}

public Course()
{
int choice;
choice=menu();
switch(choice)
{
case 1:adminmenu();
break;
case 2:usermenu();
break;
}
}

public int menu()
{
int mchoice=0;

System.out.println("Main Menu");
System.out.println("---------------------");
System.out.println("1.Admin");
System.out.println("2.User");
System.out.println("-------------------------");
System.out.print("enter your choice:");
mchoice=sc.nextInt();
return mchoice;


}
public static void main(String args[])
{
Course c=new Course();
}

public int adminmenu()
{
int schoice=0;
System.out.println("Admin menu");
System.out.println("-----------");
System.out.println("1.View");
System.out.println("2.Insert a record");
System.out.println("3.Update a record");
System.out.println("4.Delete a record");
System.out.println("5.Return to the main menu");
System.out.println("6.Exit");
System.out.println("-----------------------------");
System.out.print("enter your choice:");
schoice=sc.nextInt();
switch(schoice)
{
case 1:view();
break;
case 2:insert();
break;
case 3:update();
break;
case 4:delete();
break;
case 5:menu();
break;
case 6:System.exit(0);
}
return schoice;
}

public void usermenu() {
int uchoice=0;
System.out.println("User menu");
System.out.println("----------");
System.out.println("1.View");
System.out.println("2.Return to the main menu");
System.out.println("3.Exit");
System.out.println("--------------------");
System.out.print("enter your choice:");
uchoice=sc.nextInt();
switch(uchoice)
{
case 1:view();
break;
case 2:menu();
break;
case 3:System.exit(0);
}
}


private void delete() {
try
{
view();
System.out.println("enter the record no to be deleted:");
int n=st.executeUpdate("delete from first where no=1");
if(n>0)
System.out.println("Record is successfully deleted");
}
catch(Exception e)
{
e.printStackTrace();
}
}

private void insert() {
try
{
int n=st.executeUpdate("insert into first values(7,'Temporary')");
if(n>0)
System.out.println("Record is successfully inserted");
}
catch(Exception e)
{
e.printStackTrace();
}
}

private void update()
{
try
{
view();
System.out.print("Enter the new name:");
int n=st.executeUpdate("update first set name='c' where no=1");
if(n>0)
System.out.println("Record is successfully updated");
}
catch(Exception e)
{
e.printStackTrace();
}
}

private int view()
{
try
{
rs=st.executeQuery("select * from first");
while(rs.next())
{
System.out.println(rs.getInt(1)+"\t"+rs.getString(2));
}
}
catch(Exception e)
{
e.printStackTrace();
}
return 0;
}
}

Wednesday, May 5, 2010

getObject() example

package com.stardeveloper.servlets.db;

import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class InsertServlet extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {

res.setContentType("text/html");
PrintWriter out = res.getWriter();

out.print("");

out.print("
out.print( req.getRequestURI() );
out.print("\" method=\"post\">");
out.print("First Name :
");
out.print("
");
out.print("Last Name :
");
out.print("");
out.print("

");
out.print(" Insert Record");
out.print(" ");
out.print(" Display Records
");

out.print("");

out.close();
}

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {

res.setContentType("text/html");
PrintWriter out = res.getWriter();

out.print("");

out.print("
");

out.println("ID\tFirst Name\tLast Name\n");

// receiving parameters

String first = req.getParameter("first").trim();
String last = req.getParameter("last").trim();
boolean proceed = false;

if(first != null && last != null)
if(first.length() > 0 && last.length() > 0)
proceed = true;

// connecting to database

Connection con = null;
Statement stmt = null;
ResultSet rs = null;
PreparedStatement ps = null;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:odbc_exmp");

String sql;
sql = "INSERT INTO Names(first_name, last_name) VALUES (?,?)";
ps = con.prepareStatement(sql);
stmt = con.createStatement();

// inserting records

if(proceed) {
ps.setString(1, first);
ps.setString(2, last);
ps.executeUpdate();
}

// displaying records

rs = stmt.executeQuery("SELECT * FROM Names");
while(rs.next()) {
out.print(rs.getObject(1).toString());
out.print("\t");
out.print(rs.getObject(2).toString());
out.print("\t\t");
out.print(rs.getObject(3).toString());
out.print("\n");
}


} catch (SQLException e) {
throw new ServletException(e);
} catch (ClassNotFoundException e) {
throw new ServletException(e);
} finally {
try {
if(rs != null)
rs.close();
if(stmt != null)
stmt.close();
if(ps != null)
ps.close();
if(con != null)
con.close();
} catch (SQLException e) {}
}

out.print("");
out.close();
}
}

Wednesday, April 28, 2010

Cyberlink Power Dvd 8 CD key

Key for Delux: 4ZZTQ-FTJTG-LHS8V-THAWB-N6SPK-D3ZF5 NZRCQ-V9BCY-A9FPJ-69SGW-4KWD8-NME5H

Tuesday, April 27, 2010

JDBC interview questions

JDBC interview questions

a) OBDC is for Microsoft and JDBC is for Java applications.

b) ODBC can’t be directly used with Java because it uses a C interface.

c) ODBC makes use of pointers which have been removed totally from Java.

d) ODBC mixes simple and advanced features together and has complex options for simple queries. But JDBC is designed to keep things simple while allowing advanced capabilities when required.

e) ODBC requires manual installation of the ODBC driver manager and driver on all client machines. JDBC drivers are written in Java and JDBC code is automatically installable, secure, and portable on all platforms.

f) JDBC API is a natural Java interface and is built on ODBC. JDBC retains some of the basic features of ODBC.


what is the role of Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


when we call forName() method on Class class what happen is1)initially the class is loaded into the memory2)then it calls the static method forName()3)the static forName() method contains a static block.That static block regiser the loaded driver class with the DriverManager class

Sunday, April 25, 2010

What are the different scopes for Java variables?

What are the different scopes for Java variables?

The scope of a Java variable is determined by the context in which the variable is declared. Thus a java variable can have one of the three scopes at any given point in time.

1. Instance : - These are typical object level variables, they are initialized to default values at the time of creation of object, and remain accessible as long as the object accessible.

2. Local : - These are the variables that are defined within a method. They remain accessbile only during the course of method excecution. When the method finishes execution, these variables fall out of scope.

3. Static: - These are the class level variables. They are initialized when the class is loaded in JVM for the first time and remain there as long as the class remains loaded. They are not tied to any particular object instance.

Wednesday, April 14, 2010

win zip 12 activation code

user: TEAM ViRiLiTY

reg code: UW37E-E5UAV-9FNVH-NWQ9Z-DWXJW-087L6

Monday, April 5, 2010

How to Shutdown your Windows 7 & Vista Computer at a particular time.

Here are a few ways in which you can make your Windows Computer shutdown (or Restart) at a particular time. This can prove to be especially useful at times !

1) First, as was mentioned elsewhere on this site, you can create a shortcut, programmed to shutdown after a particular period of time as follows:
Right click on an empty area on your desktop.
Select New > Shortcut.
In the first box of the Create Shortcut Wizard, type
Shutdown -s -t 3600
Click Next. Name the shortcut : Shutdown, and click Finish.
Then select an appropriate icon for it !
Here 3600 is 3600 sec's or 60 min's or 1 hr. You can change the figure to what you wish. After the specified period of time the Computer will automatically initiate a shutdown without a warning.
2) Alternatively, Open Run and type:
at 21:30 shutdown -s
A black window will pop up and disappear.

A warning dialog box will then appear and your PC will start shutdown. Do note that the timings have to be mentioned in the 24 hr format here.

3) Using the Windows Vista Task Scheduler also offers a way to shutdown your computer at particular times.
Click Start > All Program > Accessories > SystemTools > Task Scheduler.
On the RHS, in the Actions column, click on Create Basic Task.
Give it a name like Shutdown and some add a Description too.
Click Next. Here select the Trigger. Lets say you want it to shutdown just One time, then select that option and click Next. It will ask you for the date and the time. Click Next.
In the Actions section, select Start a program. Click Next.
Here under Program/script, type:
C:\Windows\System32\shutdown.exe
and under Add arguments, type:
/s
Click Next.

You will now be presented with a Summary. Click Finish. Your Vista will now shutdown at the pre configured time.


4) You can also use a bat file for achieving this. To create a .bat file, copy paste the following in a notepad:
@echo off
title Scheduled Shutdown Batch
color A
echo Enter Time To Shutdown (Use 24 hr format, eg 21:35)
set /p stime=
cls
at %stime% ""shutdown -s -t 00"" >nul
echo Your PC Will Auto Shutdown At %stime%
echo Press Any Key To Exit
pause >nul
exit
Then in the Notepad, from the File menu on top LHS, select Save As. Save the file as Shutdown.bat

When you click the Shutdown.bat, a black box will appear, asking you to fill in the time you want the computer to shutdown. Type the time in the 24 hr format, separating the hr from the minutes by a ':' and hit enter. Thats it, your computer will shutdown at the desired time ! If you wish, you can download the ready-to-use .bat file from here.

If you wish to display a message, you can also add
-c "desired message" at the end of the shutdown command.
Like, for example:
shutdown -s -t 60 -c "Enough gaming buddy-Time to sleep"

You can also use this command to schedule your PC's Restart using the following code instead:
shutdown -r -t 60 -c "Restarting Computer" . Thanks Jerin.

5) Finally, the easiest way, is to download this freeware WinOFF. It is an utility designed to schedule the shut down of Windows computers, with several shut down modes and is fully configurable.

Some of its features are: Scheduled shut downs, either at a set time (e.g. 12:30 PM) or after a period of time (e.g. 1 hour and 25 minutes); Perform a shut down when the CPU becomes idle; Several types of shut down (shut down, restart, close session, power off, administrative shut down/restart, suspend, hibernate and lock computer, etc, etc. Worth a checkout ! Similarly, you can also try Windows Reboot Utility.

Saturday, April 3, 2010

Understanding Increment and Decrement operators in C

Understanding Increment and Decrement operators in C



Almost all programmers who work in C-based languages use the ++ and -- operators .Let's look at some interesting aspects of these operators in C.Increment/decrement operators are good examples to explain the curt (concise)syntax of


C language :

void strcpy(char *t,const char *s){
while(*t++=*s++);
}



In this strcpy function,the while loop continues copying characters from source to target ,till it reaches the end of the string ('\0' character ).

Here is another example ;can you guess the output of this code segment?

char str[]="oh",*p=str;
while(*p)
++*p++;
printf(str);


How is the expression ++*p++ treated? The postfix increment/decrement is a part of the operators with highest precedence ;the dereference and prefix increment/decrement is at the next precedence level and their associativity is from right to left .So ,the expression is treated as:(++(*(p++))).p is a pointer to string "oh".In the while loop,p++ is executed first,but it's effect does not take place till the statement execution completes.The result of p++(which is still the value of p) is dereferenced with *.For the first character it is 'o'
Now ,Prefix ++ increments the character value ,so its value is 'p' .The same happens for the next character ,'h'
,which becomes 'i'.Now the end of the character is reached ,so the while loop terminates .The printf now prints the modified string .which is "pi" .



we can use ++/-- operators to illustrate the 'maximum munch ' rule in C lexical analysis .Simply stated ,the lexical analyser (lexer ) looks for a match for the longest token .For example ,consider the expression a+b
,where a and b are integer varables.Given this as input in a C program ,the lexer might give VARIABLE (a),PLUS(+),VARIABLE(B) as output ,which is a valid sequence of tokens for compilation to succeed .

Now ,how about the expression a++b? .It is treated as a++b ,and not (a+(+b)),and results a compiler error.How about a+++b ?. It becomes ((a++)+b),so it's fine.Expression a++++b?.It is ((a++) (++b)),so it is a compiler error .Hmm how about a+++++b?.It is ((a++)++)(+b)),which is again compiler error .Note that,in all these cases ,if we use explicit white space or parenthesis ,we can get valid expressions .Note that ,in all these cases ,if we use explicit white-space or parenthesis ,we can get valid expressions :(a+(+b)),((a++)+b),
((a++) + (+b)),and ((a++) + (++b).If we try adding more +s after this ,we cannot get a valid expression for integer arguments.
Today,C-based languages (C++,Java ,etc) rule the programming world;because of this ,almost all programmers are aware of the ++ and -- operators and how powerful they are in expressing operations .What even experienced programmers do not know is that the C family was the first to introduce ++ and -- operators ! KEN THOMPSAN ,while implementing the B compiler ,noticed that increment operations generate more compact code than adding 1 to a variable and storing it back .In other words ,an increment was one instruction while adding 1 and and storing it back was more than one instruction .
So he implemented the prefix ++ (and --)operators ,and generalised it by adding a postfix version .Interestingly ,this short code -generation advantage is still true for recent languages .For example,in java ,integer increment would generate one instruction compared to the four instructions for adding 1 to the varable and storing it back .

This is the best book that I prefer to study while doing my Programming in C languge .If you want this the it is given below ,I have selected from my Amazon wish List:

Monday, March 29, 2010

C Aptitude Questions -4

Questions 104
main()
{
unsigned int i=10;
while(i-->=0)
printf("%u ",i);
}
Answer:
10 9 8 7 6 5 4 3 2 1 0 65535 65534…..
Explanation:

Since i is an unsigned integer it can never become negative. So the expression i-- >=0 will always be true, leading to an infinite loop.

Questions 105
#include
main()
{
int x,y=2,z,a;
if(x=y%2) z=2;
a=2;
printf("%d %d ",z,x);
}
Answer:
Garbage-value 0

Explanation:
The value of y%2 is 0. This value is assigned to x. The condition reduces to if (x) or in other words if(0) and so z goes uninitialized.
Thumb Rule: Check all control paths to write bug free code.

Questions 106
main()
{
int a[10];
printf("%d",*a+1-*a+3);
}
Answer:

4

Explanation:
*a and -*a cancels out. The result is as simple as 1 + 3 = 4 !


Questions 107
#define prod(a,b) a*b
main()
{
int x=3,y=4;
printf("%d",prod(x+2,y-1));
}
Answer:

10

Explanation:
The macro expands and evaluates to as:
x+2*y-1 => x+(2*y)-1 => 10

Questions 108
main()
{
unsigned int i=65000;
while(i++!=0);
printf("%d",i);
}
Answer:
1

Explanation:
Note the semicolon after the while statement. When the value of i becomes 0 it comes out of while loop. Due to post-increment on i the value of i while printing is 1.

Questions 109
main()
{
int i=0;
while(+(+i--)!=0)
i-=i++;
printf("%d",i);
}
Answer:
-1

Explanation:
Unary + is the only dummy operator in C. So it has no effect on the expression and now the while loop is, while(i--!=0) which is false and so breaks out of while loop. The value –1 is printed due to the post-decrement operator.

Questions 110
main()
{
float f=5,g=10;
enum{i=10,j=20,k=50};
printf("%d\n",++k);
printf("%f\n",f<<2);
printf("%lf\n",f%g);
printf("%lf\n",fmod(f,g));
}
Answer:
Line no 5: Error: Lvalue required
Line no 6: Cannot apply leftshift to float
Line no 7: Cannot apply mod to float
Explanation:

Enumeration constants cannot be modified, so you cannot apply ++.Bit-wise operators and % operators cannot be applied on float values. fmod() is to find the modulus values for floats as % operator is for ints

C Aptitude Questions -3

Questions 94
main(){
char a[100];
a[0]='a';a[1]]='b';a[2]='c';a[4]='d';
abc(a);
}
abc(char a[]){
a++;
printf("%c",*a);
a++;
printf("%c",*a);
}
Explanation:
The base address is modified only in function and as a result a points to 'b' then after incrementing to 'c' so bc will be printed.

Questions 95
func(a,b)
int a,b;
{
return( a= (a==b) );
}
main()
{
int process(),func();
printf("The value of process is %d !\n ",process(func,3,6));
}
process(pf,val1,val2)
int (*pf) ();
int val1,val2;
{
return((*pf) (val1,val2));
}

Answer:
The value if process is 0 !

Explanation:The function 'process' has 3 parameters - 1, a pointer to another function 2 and 3, integers. When this function is invoked from main, the following substitutions for formal parameters take place: func for pf, 3 for val1 and 6 for val2. This function returns the result of the operation performed by the function 'func'. The function func has two integer parameters. The formal parameters are substituted as 3 for a and 6 for b. since 3 is not equal to 6, a==b returns 0. therefore the function returns 0 which in turn is returned by the function 'process'.

Questions 96
void main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
}
Answer:

0 0 0 0

Explanation:
The variable "I" is declared as static, hence memory for I will be allocated for only once, as it encounters the statement. The function main() will be called recursively unless I becomes equal to 0, and since main() is recursively called, so the value of static I ie., 0 will be printed every time the control is returned.

Questions 97
void main()
{
int k=ret(sizeof(float));
printf("\n here value is %d",++k);

}
int ret(int ret)
{
ret += 2.5;
return(ret);
}
Answer:
Here value is 7
Explanation:
The int ret(int ret), ie., the function name and the argument name can be the
same. Firstly, the function ret() is called in which the sizeof(float) ie., 4 is passed, after the first expression the value in ret will be 6, as ret is integer hence the value stored in ret will have implicit type conversion from float to int. The ret is returned in main() it is printed after and preincrement.

Questions 98
void main()
{
char a[]="12345\0";
int i=strlen(a);
printf("here in 3 %d\n",++i);
}
Answer:

here in 3 6

Explanation:The char array 'a' will hold the initialized string, whose length will be counted from 0 till the null character. Hence the 'I' will hold the value equal to 5, after the pre-increment in the printf statement, the 6 will be printed.

Questions 99
void main()
{
unsigned giveit=-1;
int gotit;
printf("%u ",++giveit);
printf("%u \n",gotit=--giveit);
}

Answer:
0 65535

100) void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok here \n");
else
printf("Forget it\n");
}
Answer:
Ok here

Explanation:
Printf will return how many characters does it print. Hence printing a null character returns 1 which makes the if statement true, thus "Ok here" is printed.

Questions 101
void main()
{
void *v;
int integer=2;
int *i=&integer;
v=i;
printf("%d",(int*)*v);
}

Answer:
Compiler Error. We cannot apply indirection on type void*.

Explanation:
Void pointer is a generic pointer type. No pointer arithmetic can be done on it. Void pointers are normally used for,
1. Passing generic pointers to functions and returning such pointers.

2. As a intermediate pointer type.

3. Used when the exact pointer type will be known at a later point of time.

Questions 102
void main()
{
int i=i++,j=j++,k=k++;
printf(“%d%d%d”,i,j,k);
}

Answer:
Garbage values.

Explanation:

An identifier is available to use in program code from the point of its declaration.

So expressions such as i = i++ are valid statements. The i, j and k are automatic variables and so they contain some garbage value. Garbage in is garbage out (GIGO).

Questions 103
void main()
{
static int i=i++, j=j++, k=k++;
printf(“i = %d j = %d k = %d”, i, j, k);
}

Answer:

i = 1 j = 1 k = 1

Explanation:

Since static variables are initialized to zero by default.

Questions 104
void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
}
Answer:

Garbage values

Explanation:
The inner printf executes first to print some garbage value. The printf returns no of characters printed and this value also cannot be predicted. Still the outer printf prints something and so returns a non-zero value. So it encounters the break statement and comes out of the while statement.

C Aptitude Questions -2

Questions 83
# include
aaa() {
printf("hi");
}
bbb(){
printf("hello");
}
ccc(){
printf("bye");
}
main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[2]();
}
Answer:
bye

Explanation:
ptr is array of pointers to functions of return type int.ptr[0] is assigned to address of the function aaa. Similarly ptr[1] and ptr[2] for bbb and ccc respectively. ptr[2]() is in effect of writing ccc(), since ptr[2] points to ccc.

Questions 85
#include
main()
{
FILE *ptr;
char i;
ptr=fopen("zzz.c","r");
while((i=fgetch(ptr))!=EOF)
printf("%c",i);
}
Answer:
contents of zzz.c followed by an infinite loop

Explanation:
The condition is checked against EOF, it should be checked against NULL.

Questions 86
main()
{
int i =0;j=0;
if(i && j++)
printf("%d..%d",i++,j);
printf("%d..%d,i,j);
}
Answer:

0..0

Explanation:
The value of i is 0. Since this information is enough to determine the truth value of the boolean expression. So the statement following the if statement is not executed. The values of i and j remain unchanged and get printed.

Questions 87
main()
{
int i;
i = abc();
printf("%d",i);
}
abc()
{
_AX = 1000;
}
Answer:

1000

Explanation:
Normally the return value from the function is through the information from the accumulator. Here _AH is the pseudo global variable denoting the accumulator. Hence, the value of the accumulator is set 1000 so the function returns value 1000.
Questions 88
int i;
main(){
int t;
for ( t=4;scanf("%d",&i)-t;printf("%d\n",i))
printf("%d--",t--);
}
// If the inputs are 0,1,2,3 find the o/p
Answer:
4--0

3--1

2--2

Explanation:Let us assume some x= scanf("%d",&i)-t the values during execution will be,

t i x

4 0 -4

3 1 -2

2 2 0

Questions 89
main(){
int a= 0;int b = 20;char x =1;char y =10;
if(a,b,x,y)
printf("hello");
}
Answer:
hello

Explanation:
The comma operator has associatively from left to right. Only the rightmost value is returned and the other values are evaluated and ignored. Thus the value of last variable y is returned to check in if. Since it is a non zero value if becomes true so, "hello" will be printed.

Questions 90
main(){
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");
}
Explanation:
i is an unsigned integer. It is compared with a signed value. Since the both types doesn't match, signed is promoted to unsigned value. The unsigned equivalent of -2 is a huge value so condition becomes false and control comes out of the loop.

Questions 91
In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'.
main(){
int * j;
void fun(int **);
fun(&j);
}
void fun(int **k) {
int a =0;
/* add a stmt here*/
}
Answer:

*k = &a

Explanation:
The argument of the function is a pointer to a pointer.

Questions 92:
What are the following notations of defining functions known as?
int abc(int a,float b)
{
/* some code */
}
ii. int abc(a,b)
int a; float b;
{
/* some code*/
}
Answer:

i. ANSI C notation

ii. Kernighan & Ritche notation

Questions 93
main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);

}

Answer:
300
Explanation:
The pointer points to % since it is incremented twice and again decremented by 2, it points to '%d\n' and 300 is printed.