Tuesday, June 4, 2013

Principles of Procedural Programming

Procedural programming

As a computer program marks coding so that is calling for Procedural Programming. That means a record of programming for telling into computer. And this is telling for step-by step. Procedural programming languages take in JAVA, C, C++, FORTRAN, Pascal, and Basic etc...

Java
A high-level programming language developed by Sun Microsystems... and having advantage of using this java that is we can take example of you have Visual Basic and that is taking more space but java is like MB so that is not taking that much of space. Oak was failed so in 1995 Sun changed the name to Java and made to order the language.

Java is an object-oriented language like to C++, but basic to remove language features that reason common programming errors. Collected Java code can run on most computers because Java interpreters and runtime environments Java is a common reason programming language with a number of features Small Java applications are called Java applets, nowadays this famous computer language.

And java has some principles such as

·         Statement                                                                
·         Function
·         Selection
·         Module
·         Subroutine
·         Parameter/Argument
·         Iteration/repetition
·         Variables
·         Procedure/ procedure cal
·         Sequence
·         Loop
·         Algorithms

Statement

Way plus constructors are runs of statements, next to with variable meanings. The statements give the sequence of events to be makes when a process or constructor is call up. They can change the value of variables, make output, process input, or respond to user input device action.

Here having some statement such as

·         Looping statements
·         While statements
·         Do-While statements
·         For statements etc...
On example for statement
If (num> 18)
{
System.out.println (“great Then" + num);
 }

Function

Function mean will go back an only one value after called. And this is use full to insert functions and it is consist of input parameters. And it is Support for closures and higher order functions and it is supporting for lazy assessment.

Selection

A Selection means a Selector for use with a limit or Value anywhere careful link of Parameters and/or Values is wanted.The principle is one as the character of the Parameter and/or Value to use in creation a collection. The Selector line identifies the reason symbols.


If/else selection

•          Perform action only when state is right
•          do different specific action when state is false
•          It’s like qualified operator


public static void selectionSort1(int[] x) {
for (int i=0; i<x.length-1; i++) {
for (int j=i+1; j<x.length; j++) {
if (x[i] > x[j]) {
                //... Exchange elements
int temp = x[i];
x[i] = x[j];
x[j] = temp;
            }
        }
    }
}




Module

A module or a modulemeaning can be defined as a logical unit of rest of files. Income and its needs that can be side put together and organize in the module store. This is use again by some other function.

And below is the main divide of a module such as

Name of the module
List of introduction modules
List of classes limited in this module

Public class Model extends java.util.Observable {   
           
            privateint counter;       //primitive, automatically initialised to 0

            public Model(){

                        System.out.println("Model()");

Subroutine

It will take us a while mainly of the part to get from first to last come again? This total means in fact. This is performance part, of the "black box". This is including interface part. They are the orders that the computer carry out when the method is called. Subroutines can control any of the statement.And each declaration can name only one parameter.


modifiers  return-type  subroutine-name  ( parameter-list ) {
statements
}

Parameter/Argument

Parameters are the variables that are programmed as piece of a method declaration. Each parameter must have a single name and a clear data style. Zero or additional String objects or an array of them may be agreed as the parameter for that purpose.

Identifying method arguments

When you identify a method, you know how to pass in order for it to make use of. These real advices are inside addition following the method name. And before program is shown below, but this time the arguments in the calls are highlighted.



Iteration/repetition

It is mean repeating data process

An example for using this we can take a word, phrase, or clause additionalThen once in a short means of access address on a point. Iteration is a generalization of cursor. Useless or chance repetition a tautology or pleonasm is a type of disorder that may divert or turn off a person who reads.Iteration, similar to friction, is expected to make heat in its place of development iteration is a single development cycle.

public static void cont (int n) {
while (a> 0) {
System.out.println (n);
      a = a-1;
    }
System.out.println ("Blastoff!");
  }


Variables

A variable is a container that holds values that are used in a Java program. Every variable have to be declared to make use of a data type. For example, a variable might be stated to use one of the eight primitive data types: int, long, float, double, char or Boolean. String and, every variable must be given a first value before it can be used.

Here has some data type such as

·         Int: that is Integer that mean it if for number
·         Long: that is mean of large number
·         Float: this is using for decimal number like 1.5

·         Double: this is use for large decimal number like 1322222548788.5
·         Character: this is use for one letter example BCAS
·         Boolean: it is mean True or False (1,0)
·         String: this use for text


Example

{
Int Arm=1;
Int arm2=2;
Int tot=arm+arm2;
}

Procedure/ procedure call

An ordered set of tasks for performing some action that mean it is checking for one buy one. That one would go after in order to complete a task. That is step-by-step order of activities or track of action that must be go behind in the same order to correctly do a task. Repetitive procedures are called routines

Public class arm
{
Public static void main (String args[])
{
Int a = 5;
Int b= 6;
Int c= a+b;
System.out.println(“answer is”+c);
}
}

This is small example for this procedure.

Sequence

Serial agreement in which things follow in logical arrange or a regular model. Arrange in a sequenceDetermine the order of constituents inAll programmers are known with writing in order programs.You've most likely in print a program that displays "Welcome to java” or sorts a file of names, or computes a list of main numbers. These are sequential programs. Each has an opening, an end, a sequence, and at any set time through the runtime of the program there is an only one end of finishing.A strand is a on its own in order run of control inside a program.

Example…

DefMonth = ["Jan","Feb","Mar","Apr",”May”,”June”,”July”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”];

Loop

A loop is a method of do again outline of code more Then once. The block of code limited within the loop will be meeting all over again and again until the condition needed by the loop is meeting.

For example, you could set up a loop to print out the even numbers between 0 and 10. The code that gets complete all time the loop is run will be the printing out of an even number, the order the loop is looking to meet is getting 10. Int[] num(1, 2, 3, 4, 5, 6, 7, 8, 9);

Here having some type such as

·         Indeterminate
·         Determinate

Indeterminate

That meanan unfixed loop does not know how many times it will run.
Determinate

A determinate loop identifies closely how many times it will loop.

Algorithms

Algorithms the polymorphic algorithms explain here are pieces of reusable functionality make available by the Java platform. All of them come from the group of class, and all get the type of static way whose first fight is the group on which the process is to be complete.

publicint[] selectionSort(int[] data){
intlenD = data.length;
int j = 0;
inttmp = 0;
for(int i=0;i<lenD;i++){
    j = i;
for(int k = i;k<lenD;k++){
if(data[j]>data[k]){
        j = k;
      }
    }
tmp = data[i];
data[i] = data[j];
data[j] = tmp;
  }
return data;
}








No comments:

Post a Comment