Monday, March 28, 2016

transaction

transaction

A TRANSACTION IS AN EVENT OR HAPPENING THAT CHANGES AN ORGANISATION "S FINANCIAL POSITION AND/OR ITS EARNING.

Sunday, March 6, 2016

form to insert data in database

<html>
  
   <head>
      <title>Add New Record in MySQL Database</title>
   </head>
  
   <body>
      <?php
         if(isset($_POST['add'])) {
            $dbhost = 'localhost';
            $dbuser = 'prakash';
            $dbpass = '123';
            $conn = mysql_connect($dbhost, $dbuser, $dbpass);
           
            if(! $conn ) {
               die('Could not connect: ' . mysql_error());
            }
           
            if(! get_magic_quotes_gpc() ) {
               $emp_name = addslashes ($_POST['emp_name']);
               $emp_address = addslashes ($_POST['emp_address']);
            }else {
               $emp_name = $_POST['emp_name'];
               $emp_address = $_POST['emp_address'];
            }
           
            $emp_salary = $_POST['emp_salary'];
           
            $sql = "INSERT INTO employee ". "(emp_name,emp_address, emp_salary,
               join_date) ". "VALUES('$emp_name','$emp_address',$emp_salary, NOW())";
              
            mysql_select_db('test_db');
            $retval = mysql_query( $sql, $conn );
           
            if(! $retval ) {
               die('Could not enter data: ' . mysql_error());
            }
           
            echo "Entered data successfully\n";
            
            mysql_close($conn);
         }else {
            ?>
           
               <form method = "post" action = "<?php $_PHP_SELF ?>">
                  <table width = "400" border = "0" cellspacing = "1"
                     cellpadding = "2">
                 
                     <tr>
                        <td width = "100">Employee Name</td>
                        <td><input name = "emp_name" type = "text"
                           id = "emp_name"></td>
                     </tr>
                 
                     <tr>
                        <td width = "100">Employee Address</td>
                        <td><input name = "emp_address" type = "text"
                           id = "emp_address"></td>
                     </tr>
                 
                     <tr>
                        <td width = "100">Employee Salary</td>
                        <td><input name = "emp_salary" type = "text"
                           id = "emp_salary"></td>
                     </tr>
                 
                     <tr>
                        <td width = "100"> </td>
                        <td> </td>
                     </tr>
                 
                     <tr>
                        <td width = "100"> </td>
                        <td>
                           <input name = "add" type = "submit" id = "add"
                              value = "Add Employee">
                        </td>
                     </tr>
                 
                  </table>
               </form>
           
            <?php
         }
      ?>
  
   </body>
</html>

 <html>
  
   <head>
      <title>Add New Record in MySQL Database</title>
   </head>
  
   <body>
      <?php
         if(isset($_POST['add'])) {
            $dbhost = 'localhost:3036';
            $dbuser = 'root';
            $dbpass = 'rootpassword';
            $conn = mysql_connect($dbhost, $dbuser, $dbpass);
           
            if(! $conn ) {
               die('Could not connect: ' . mysql_error());
            }
           
            if(! get_magic_quotes_gpc() ) {
               $emp_name = addslashes ($_POST['emp_name']);
               $emp_address = addslashes ($_POST['emp_address']);
            }else {
               $emp_name = $_POST['emp_name'];
               $emp_address = $_POST['emp_address'];
            }
           
            $emp_salary = $_POST['emp_salary'];
           
            $sql = "INSERT INTO employee ". "(emp_name,emp_address, emp_salary,
               join_date) ". "VALUES('$emp_name','$emp_address',$emp_salary, NOW())";
              
            mysql_select_db('test_db');
            $retval = mysql_query( $sql, $conn );
           
            if(! $retval ) {
               die('Could not enter data: ' . mysql_error());
            }
           
            echo "Entered data successfully\n";
            
            mysql_close($conn);
         }else {
            ?>
           
               <form method = "post" action = "<?php $_PHP_SELF ?>">
                  <table width = "400" border = "0" cellspacing = "1"
                     cellpadding = "2">
                 
                     <tr>
                        <td width = "100">Employee Name</td>
                        <td><input name = "emp_name" type = "text"
                           id = "emp_name"></td>
                     </tr>
                 
                     <tr>
                        <td width = "100">Employee Address</td>
                        <td><input name = "emp_address" type = "text"
                           id = "emp_address"></td>
                     </tr>
                 
                     <tr>
                        <td width = "100">Employee Salary</td>
                        <td><input name = "emp_salary" type = "text"
                           id = "emp_salary"></td>
                     </tr>
                 
                     <tr>
                        <td width = "100"> </td>
                        <td> </td>
                     </tr>
                 
                     <tr>
                        <td width = "100"> </td>
                        <td>
                           <input name = "add" type = "submit" id = "add"
                              value = "Add Employee">
                        </td>
                     </tr>
                 
                  </table>
               </form>
           
            <?php
         }
      ?>
  
   </body>
</html>

java

 java
  • Can we overload main method ?
  • Constructor returns a value but, what ?
  • Can we create a program without main method ?
  • What are the 6 ways to use this keyword ?
  • Why multiple inheritance is not supported in java ?
  • Why use aggregation ?
  • Can we override the static method ?
  • What is covariant return type ?
  • What are the three usage of super keyword?
  • Why use instance initializer block?
  • What is the usage of blank final variable ?
  • What is marker or tagged interface ?
  • What is runtime polymorphism or dynamic method dispatch ?
  • What is the difference between static and dynamic binding ?
  • How downcasting is possible in java ?
  • What is the purpose of private constructor?
  • What is object cloning ?

Friday, March 4, 2016

JAVA PROGRAM(ALPHABET PATTERN)

 JAVA  PROGRAM(ALPHABET PATTERN)
A
AB
ABC
ABCD


 /*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication23;

/**
 *
 * @author Prakash
 */

public class JavaApplication23 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
     
  for(int i=1;i<5;i++)
        {
            int a=65;                          //ASCII value of A
            for(int j=1;j<=i;j++)
              {
                System.out.print((char)a);
                a++;
              }
          System.out.println();
        }
    }   
}

2.   A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA
ABCDEFEDCBA
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication23;

/**
 *
 * @author Prakash
 */
//enum week{
 //   sun,mon,tue,wed,thurs,fri,sat
//};
import java.util.*;  // import java util 
public class JavaApplication23 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
  Scanner scr=new Scanner(System.in); // create scanner obj
int n;
System.out.println("Enter the number of rows. ");
n=scr.nextInt();  // accept a number


char c;
for(int i=1;i<=n;++i)        // FOR LOOP FOR NUMBER OF ROWS
{
c='A';
for(int j=i;j<n;++j)        // FOR LOOP FOR PRINTING SPACES
{
System.out.print(" ");
}
for(int k=1;k<=i;++k)      // FOR LOOP FOR PRINTING ALPHABETS IN DESCENDING ORDER  
{
System.out.print(c);
++c;
}
c-=2;
for(int l=1;l<i;++l)      // FOR LOOP FOR PRINTING ALPHABETS IN ASCENDING ORDER
{
System.out.print(c);
--c;
}
System.out.println();    // INTRODUCING NEW LINE

}

    }   

}


output
Enter the number of rows. 
6
     A
    ABA
   ABCBA
  ABCDCBA
 ABCDEDCBA
ABCDEFEDCBA



      A
    BAB
   CBABC
  DCBABCD
 EDCBABCDE
FEDCBABCDEF


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication23;

/**
 *
 * @author Prakash
 */
//enum week{
 //   sun,mon,tue,wed,thurs,fri,sat
//};
import java.util.*;  // import java util 
public class JavaApplication23 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
  Scanner scr=new Scanner(System.in);
int n;
System.out.println("Enter the number of rows. ");
n=scr.nextInt();

char ch='A';
char c;
for(int i=1;i<=n;++i)        // FOR LOOP FOR NUMBER OF ROWS
{
c=ch;
for(int j=i;j<n;++j)        // FOR LOOP FOR PRINTING SPACES
{
System.out.print(" ");
}
for(int k=1;k<=i;++k)      // FOR LOOP FOR PRINTING ALPHABETS IN DESCENDING ORDER  
{
System.out.print(c);
--c;
}
c+=2;
for(int l=1;l<i;++l)      // FOR LOOP FOR PRINTING ALPHABETS IN ASCENDING ORDER
{
System.out.print(c);
++c;
}
System.out.println();    // INTRODUCING NEW LINE
++ch;                   //  INCREMENTING VALUE OF CH FOR NEXT ITERATION
}

} // end of main method
} // end of main class

/* OUTPUT

    }   
}


run:
Enter the number of rows. 
6
     A
    BAB
   CBABC
  DCBABCD
 EDCBABCDE
FEDCBABCDEF
BUILD SUCCESSFUL (total time: 4 seconds)


Tuesday, March 1, 2016

ANDROID

DOWNLOAD FILE AND USE APP

ANDROID FIRST APP

CREATE A ANDROID APP
ACCEPT NAME  AND PRINT HII + NAME

FRIST OPEN eclipse
 FILE TAB
OPEN NEW PROJECT AND SELECT ANDROID APPLICATION  PROJECT
THEN APPLICATION NAME
THEN NEXT
THEN NEXT ---------> You CHANGE ICON THEN BROWSERS IMAGE
THEN NEXT -----> AND FINISH
THEN OPEN
FOLDER RES --->
THEN OPEN LAYOUT FOLDER 
AND OPEN activty_main.xaml
and


and open values folder and select string.xaml file and 
code
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">greation</string>
    <string name="hello_world">Hello world!</string>
    <string name="menu_settings">Settings</string>
 <string name="accept">plz enter name</string>
<string name="show">show</string>
<string  name="a"> hello i am niit student</string>

</resources>

AND activity_main in code 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="98dp"
        android:layout_marginTop="112dp"
        android:onClick="showresult"
        android:text="@string/show" />

    <EditText
        android:id="@+id/accept"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button1"
        android:layout_alignParentTop="true"
        android:layout_marginTop="26dp"
        android:ems="10" />

    <EditText
        android:id="@+id/result"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button1"
        android:layout_centerVertical="true"
        android:ems="10" >

        <requestFocus />
    </EditText>

</RelativeLayout>



AND open src folder  and open Mainactivity.java


and code

package com.example.greation;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    public void showresult(View v)
    {
    EditText et = (EditText)findViewById(R.id.accept);
    String s = et.getText().toString();
    TextView obj = (TextView)findViewById(R.id.result);
    obj.setText("hello"+s);
   
    }
    

}

plz Download FOLDER
download app

ANDROID

Hii friend,
.                I'm start  Android  Tutorial Today . ANY Query in ANDROID PLZ CONTACT ME .

Tuesday, February 23, 2016

PROGRAM

PROGRAM

1.       Wap that print that out the even number 2,4,…..20, using for loop.
2.       Write a program to read in a square, two-d array and display its transpose.
3.       Write a program to accept 10 number I an array. Now print the elements of array. Sort the array and print the ADC & DSc sorted order without using method.
4.        Write a program accept to concatenate two strings without using library function.
5.       Write a program to reverse a string without function.
6.       Write a program count the number of vowel in string.
7.       Write a program to find the length of a string without using library function.
8.       Write a program which replace all vowels in string with character ‘n’.
9.       Write a program takes a number as input and print the sum of all the digits as output.
10.   Write a program takes a number as input & check it is prime number & not. Print the result.
11.   Write a program takes a number as input & print the factorial of the number as output.
12.   Write a program which takes a sentence as input and count the number of space in rhe sentence. Print the result.
13.   Write a program which accept two numbers as input. Find the HCF of two number.
14.   Write a program which takes a sentence as input and then count for the total number of word in the sentence.
15.   Write a program which takes two matrices as input & then add the two matrices. Then print the find resultant matrix.
16.   Write a program in ‘c’ using while loop to find factorial of a positive integer.
17.   Write a program for the no of vowel & consonants in a line of text entered from console.
18.   Write a program to accept any 3 digit integer number 7 display the word equivalent representation of given number.
19.   Write a program to calculate the electricity bill using if-elseif---
    Given the number of units consumed, unit charges are as followers:
·         For frist 50 units         rs 0.50/ units
·         For next 100 units      rs 0.75/ units
·         For next 100 units      rs 1.20 units
·         For next above 250     rs 1.50/units
  20. Star pattern
    *
   ***           
  *****
 *******

*********

Tuesday, December 8, 2015

Introduction to C Language


C is one of the most popular computer language developed at AT&T’S Bell laboratories of USA in 1972 .It was developed by Dennis Ritchie. It is also called mid level language.
Today when the computer technology is on it's highest era and the advance programming languages like C++,C# and JAVA is very popular among developers many of us may think that C is now become less important. But this is not true since, C is still very popular and important language for it's following features.

Advantage Associated with C Language

  1. Simple to use and understand. You can later on migrate to C++, C# or java. Hence, preferring two-step learning process.
  2. C++,C# or java using oops technology that actually require core C language element.
  3. Operating system like window, Linux, UNIX is still written in C. And so if you are to extend any of above operating system to work with new devices you must need to write device driver program. And are exclusively written in C.
  4. C has best performance record. Because of highest execution among all other language (due to its verity of data type and powerful operator).
  5. Enormous electronic gadgets like mobile phone, digital camera, I-pod, microwaves, ovens, washing machine are using a microprocessor (chip) which contains an operating system and a program which are embedded in these devices which must have fast execution within limited amount of memory. And it is C who comes to show its smartness here.
  6. Professional 3D computer game like spaceship and firing bullet need speed to match player’s inputs and C is again hero here.
  7. Its structured, high level, machine independent language that provide programmer a freedom to portability facility.(One computer to another).
  8. C compilers combine the facility of an assembly language plus high level language. And hence capable to write both operating system and business pack. Many C compilers are itself written in C that is available in market.
  9. Another very important feature of C is its ability to extend itself .We can continuously add our own function to its library is convents.

Disadvantages Associated with C Language

  1. There is no strict type checking (for ex: we can pass an integer value for the floating data type).
  2. As the program extends it is very difficult to fix the bugs.
  3. There is no runtime checking.

Basic Structure of C program

  1. Documentation Section
  2. Link Section
  3. Definition Section
  4. Global Declaration Section
  5. -----------------------------------------------------------------
  6. main function section
  7. {
  8. //Declaration part
  9. //Executable part
  10. }
  11. -----------------------------------------------------------------
  12. Sub program section
  13. Function 1
  14. Function 2
  15. --
  16. -- //user defined function
  17. --
  18. Function n

Why C is called middle level language?


C is called middle-level language because it is actually bind the gap between a machine level language and high-level languages. User can use c language to do System Programming (for writing operating system) as well asApplication Programming (for generate menu driven customer billing system ). That's why it is called middle level language.
High level - Ada , Modula-2 , Pascal, COBOL, FORTRAN, BASIC
Middle level - Java, C++, C, FORTH, Macro-assemble
Low level - Assemble

Tuesday, December 1, 2015

Clustered Index & Nonclustered Index

Clustered Index 

A clustered index is an index that sorts and stores the data rows in the table based on their key values. Therefore, the data is physically sorted in the table when a clustered index is defined on it. Only one clustered index can be created per table. Therefore, you should build the clustered index on attributes that have a high percentage of unique values and are not modified often. In a clustered index, data is stored at the leaf level of the B- Tree.
 SQL Server performs the following steps when it uses a clustered index to search for a value:
SQL Server obtains the address of the root page from the sysindexes table, which is a system table containing the details of all the indexes in the database. The search value is compared with the key values on the root page. The page with the highest key value less than or equal to the search value is found. The page pointer is followed to the next lower level in the index. Steps 3 and 4 are repeated until the data page is reached. The rows of data are searched on the data page until the search value is found. If the search value is not found on the data page, no rows are returned by the query.

Nonclustered Index 

Similar to the clustered index, a nonclustered index also contains the index key values and the row locators that point to the storage location of the data in a table. However, in a nonclustered index, the physical order of the rows is not the same as the index order. Nonclustered indexes are typically created on columns used in joins and the WHERE clause. These indexes can also be created on columns where the values are modified frequently. SQL Server creates nonclustered indexes by default when the CREATE INDEX command is given. There can be as many as 999 nonclustered indexes per table. The data in a nonclustered index is present in a random order, but the logical ordering is specified by the index. The data rows may be randomly spread throughout the
table. The nonclustered index tree contains the index keys in a sorted order, with the leaf level of the index containing a pointer to the data page.
 SQL Server performs the following steps when it uses a nonclustered index to search for a value:

SQL Server obtains the address of the root page from the sysindexes table. The search value is compared with the key values on the root page. The page with the highest key value less than or equal to the search value is found. The page pointer is followed to the next lower level in the index. Steps 3 and 4 are repeated until the data page is reached. The rows are searched on the leaf page for the specified value. If a match is not found, the table contains no matching rows. If a match is found, the pointer is followed to the data page and the requested row is retrieved.

INDEX IN SQL

An index is an on-disk structure associated with a table or view that speeds retrieval of rows from the table or view. An index contains keys built from one or more columns in the table or view. These keys are stored in a structure (B-tree) that enables SQL Server to find the row or rows associated with the key values quickly and efficiently.
A table or view can contain the following types of indexes:
  • Clustered
    • Clustered indexes sort and store the data rows in the table or view based on their key values. These are the columns included in the index definition. There can be only one clustered index per table, because the data rows themselves can be sorted in only one order.
    • The only time the data rows in a table are stored in sorted order is when the table contains a clustered index. When a table has a clustered index, the table is called a clustered table. If a table has no clustered index, its data rows are stored in an unordered structure called a heap.
  • Nonclustered
    • Nonclustered indexes have a structure separate from the data rows. A nonclustered index contains the nonclustered index key values and each key value entry has a pointer to the data row that contains the key value.
    • The pointer from an index row in a nonclustered index to a data row is called a row locator. The structure of the row locator depends on whether the data pages are stored in a heap or a clustered table. For a heap, a row locator is a pointer to the row. For a clustered table, the row locator is the clustered index key.
    • You can add nonkey columns to the leaf level of the nonclustered index to by-pass existing index key limits, 900 bytes and 16 key columns, and execute fully covered, indexed, queries.