Monday, 20 October 2014


Key Features of Procedural Programs

Predefined functions:


A predefined function can be placed after a variable and parameter.
A predefined function is a charAt which lets you find a specific position in a string e.g;

String sName;
sName=’Maison’;
char cPosition;
cPosition=sName.charAt(0);
System.out.println(“The letter at position 0 is”+cPosition)

Another predefined function is string.replace() which lets you replace a string.

Local Variables:
Local variables have the largest scope compared to the other variables. This variable is only accessible from the function or block where it is declared. Every local variable is immediately contained in a block ({...}) Local variable declaration statements can be mixed with other kinds of statements if they are in the same block. Local variables declaration have one single modifier and only one can be used. Local variables aren't actually given default initial values, they have to be initialized before they are used.


public class Cat{
  public void kittenAge(){
     int age = 0;
     age = age + 7;
     System.out.println("Kitten age is : " + age);
  }
public static void main(String args[]){
     Kitten = new Kittent();
     test.kittenAge();
  }
}


Global Variables:

Global variables are variables that are visible throughout the program unless hidden, the set of all global variables is known as the global environment. To define Global Variable you need to make use of static keyword.



public class Software {
     public static int a;
     public static int b;


}

Parameter passing:
Parameter passing allows the variable values to be passed through the program to the procedure, look at the image of the code below, specifically, 'System.out.println( "Some Text Here" );', that's what will be displayed.




























Modularity:
Modularity is the definition of a modular programme. Modular programming is breaking up a computer program into separate sub-programs. A module is a separate software component. It's often used in a wide range of applications and functions with other components of the system.


Procedures:
Procedure is the way something is finished and created in, for example a method. This is a detailed step by step process to give a finished end product, for example, a final code. Procedure is the principle of giving a systematic order of statements, functions and programmes.

Programming libraries:
A programming library or libraries(plural) is a pre-compiled routine like code, class, procedure and script which is able to be specified and used by a programmer when developing an application programme.

Procedural programming paradigm:
Procedural programming paradigm is a step by step method of programming. It uses a list of instructions to develop a routine or sub-routine. Event driven programming paradigm is the event in which a computer is given events to complete, for example, mouse click, key presses, sensor outputs. OOP or object oriented programming is another programming paradigm that represents the concept of 'objects' that have data fields (attributes that describe object).

Two example of programming languages
The first example of a programming language is C++, C++ is a intermediate-level language with object oriented programming features, originally designed to enhance the C language.

int main (int argc, char *argv[])
int stars;
int count;
printf("How many stars would you like?")
scanf("%d" ,&stars);
for (count=0;count<stars;count++)
printf ("*");
return 0;

The second example is Pascal, Pascal is best known for its structured coding. Pascal is actually in chronological order. 

Program mystars(output);
  Var
    Stars: integer;
    Count: integer;
  Begin
   writeln ('How many stars would you like?');
   readln (stars);
   for count :=1 to stars do
    writeln('*');
    end.

Samples of code including: if, else, else if, for, int, char, String, double and boolean
This example is of 'else', 'else if' and finally 'if' which is used for answering questions.

Public static void main (string [] args) (
Int user= 18
If (user <= 18 (
System.out.println (“user is 18 or younger”)
}
Else if (user >18 && user < 40){
}
Else{
System.out.println (“user is older than 40”);

This example is about 'for', a keyword is programming.

int count;
printf("How many stars would you like?")
scanf("%d" ,&stars);
for (count=0;count<stars;count++)
printf ("*");
return 0;

Int means integer and it basically declares a variable
  int iEggscontent=64
        int iLargeEggs=50%
        int iMediumEggs=30%
        int iSmallEggs=20%  

Char is pretty much just character and an example of char is pretty much a letter.
 charAt      String I = String(“Swaf Lord”); char result = I.charAt(0);

A string is declaring a position, for example, the position of this string is college.

String sPhrase="Middlesbrough college is located on Dock Street";     //Declare middlesbrough college 
bAnswer=sPhrase.contains("college");

A double is a variable that has numbers with decimals and if an object is static, it can be called from multiple methods. Here's an example:

public class DoubleExampleJava { public static void main(String[] args)
{ double db=34;
System.out.println("double data :"+db); } }

A boolean declares if a variable is a true or false statement. Here's an example.

public static void main(String []args){
     String sPhrase="Middlesbrough college is located on Dock Street";     //Declare middlesbrough college
     boolean bAnswer=false;
     bAnswer=sPhrase.contains("Dock");
     if (bAnswer==true);{  
     System.out.println("The Dock was once operational and had many ships anchored there ");
     } //end if in lif

Modular Elements Are Important
A modular approach uniquely encourages taking one step at a time, promoting teamwork, collaboration and, most importunately, promotes testing on small and isolated units prior to integrating them into a large system. There's several advantages to using a modular approach, the first is that it's easy to understand small sections of code in modular programming and you can store the code across multiple files. Modular programming also allows collaborative programming and duplication of code isn't possible in modular, the programmers create a single procedure for code. The errors are localized to a subroutine or function and it's easier to find all the errors. The code is also used in multiple applications in modular programming and the code can be simpler and shorted in modular due to less needing to be written.

No comments:

Post a Comment