Key Features of Procedural Programs
Pre-defined Functions
A pre-defined Function is lots of pre existing code that is there for the end user to use. Most programming IDE's will have pre-defined functions so that it easier on the user and written in style of English so users can understand what is going on. an example of a pre-defined function in Java is .length() this will look at how many characters are in the string and tell you the number of letters:
String sGreeting;
sGreeting="Hello";
int length;
sGreeting.length();
System.out.println("Greeting " + sGreeting);
Local Variables
A local variable is something that is declared within the body of a method, you are not declaring this variable in the public class because that would be a Global Variable. When you create a local Variable other methods in that class are not even aware that its there. an example would be declaring it in the public static void main body:
public class HelloApp
{ public static void main(String[] args) { String sHelloMessage; helloMessage = "Hello World"; System.out.println(sHelloMessage); }}
Global Variables
A global variable must be available everywhere, it must also be able to be used by function at any time. It's like given a piece of information about you to the public and they can do what they wish with that information.
Parameter Passing
The basic understanding of parameter passing is a variable or value that you can pass in to a function. Each parameter must have a unique name and a defined data type.
In Java you put parameter under the main public class for example:
{ public static void main(String[] args)
this is a parameter because the variable or value is being passed into a function.
{ public static void main(String[] args)
this is a parameter because the variable or value is being passed into a function.
Modularity
Modularity in programming is Breaking down the design of a program into individual components. these can be programmed and tested independently. It is a requirement for effective development and maintenance of large programs and projects.
Procedures
A procedure performs a specific task in the code. A function will return a value whereas a procedure will just execute the commands. this an example in C
void display( int n ) {
printf( "The value is %d", n );
Programming Libraries
A Programming library is pre-compiled code that is stored for later use in a program. Libraries are particularly useful for storing frequently used routines because you do not need to explicitly link them to every program that uses them.
A Programming library is pre-compiled code that is stored for later use in a program. Libraries are particularly useful for storing frequently used routines because you do not need to explicitly link them to every program that uses them.
Procedural Programming paradigm
Procedural Programming is a list or set of code that tells the computer what to do step by step and how to perform from the first code to the second. Any giving procedure maybe called out at any time during a programs execution.
Procedural Programming is a list or set of code that tells the computer what to do step by step and how to perform from the first code to the second. Any giving procedure maybe called out at any time during a programs execution.
Example of two programming languages
Two examples are Java and Visual Basic
Two examples are Java and Visual Basic
Simple Java code and fucntions
int - this stores denary data in the variable for example you could have
int iNumber = 7;
the int is storing the phrase iNumber and that is = to 7
if/else - the if statement executes a certain part of the code if the value is true for example
int iTrue = 7;
int iFalse = 10;
if (iTrue < iFalse) {
System.out.println("This is True");
}else {
System.out.println("this is false");
}
this is saying if iTrue is less than iFalse then execute the first System.out.println but if iTrue is bigger it will execute the else statement.
char - the char variable stores an alphabetical letter for later use. For example
char cFirstInitial = 'J';
this will store the letter J until declared.
String - The string variable will hold a piece of text. For example.
String sMyName = "My name is Jeff";
this holds the value My name is Jeff to use in a println or anything.
double - the double variable will introduce the point system into number. For example.
double numberone, numbertwo, Answer;
numberone = 10.5;
numbertwo = 12.9;
Answer = numberone + numbertwo ;
System.out.println("The answer is " + Answer);
the double holds the numbers 10.5 and 12.9 then is added together to show the answer.
Boolean
A Boolean value is one with two choices: true or false, yes or no, 1 or 0. In Java, there is a variable type for Boolean values So instead of typing int or double or string, you just type boolean (with a lower case "b"). After the name of you variable, you can assign a value of either true or false. an Example would be
boolean bExample = false;
if (condition){
bExample = true
}
if (bExample = true){
Statements
int - this stores denary data in the variable for example you could have
int iNumber = 7;
the int is storing the phrase iNumber and that is = to 7
if/else - the if statement executes a certain part of the code if the value is true for example
int iTrue = 7;
int iFalse = 10;
if (iTrue < iFalse) {
System.out.println("This is True");
}else {
System.out.println("this is false");
}
this is saying if iTrue is less than iFalse then execute the first System.out.println but if iTrue is bigger it will execute the else statement.
char - the char variable stores an alphabetical letter for later use. For example
char cFirstInitial = 'J';
this will store the letter J until declared.
String - The string variable will hold a piece of text. For example.
String sMyName = "My name is Jeff";
this holds the value My name is Jeff to use in a println or anything.
double - the double variable will introduce the point system into number. For example.
double numberone, numbertwo, Answer;
numberone = 10.5;
numbertwo = 12.9;
Answer = numberone + numbertwo ;
System.out.println("The answer is " + Answer);
the double holds the numbers 10.5 and 12.9 then is added together to show the answer.
Boolean
A Boolean value is one with two choices: true or false, yes or no, 1 or 0. In Java, there is a variable type for Boolean values So instead of typing int or double or string, you just type boolean (with a lower case "b"). After the name of you variable, you can assign a value of either true or false. an Example would be
boolean bExample = false;
if (condition){
bExample = true
}
if (bExample = true){
Statements
Else if
You can have multiple else if statements declared. This means that if you have an if that's not going to work it can carry out the else if statements as back up for ex
if(Boolean_expression 1){
//Executes when the Boolean expression 1 is true
}else if(Boolean_expression 2){
//Executes when the Boolean expression 2 is true
}else if(Boolean_expression 3){
//Executes when the Boolean expression 3 is true
}else {
//Executes when the none of the above condition is true.
}
M1
//Executes when the Boolean expression 1 is true
}else if(Boolean_expression 2){
//Executes when the Boolean expression 2 is true
}else if(Boolean_expression 3){
//Executes when the Boolean expression 3 is true
}else {
//Executes when the none of the above condition is true.
}
M1
Why are Modular Elements important?
A programming design style in which a program is split up into small chunks that each do one part of the task. Modules can be used many times as its easier to test a small module than the whole program at any giving time. In the instance of having teams, different modules can be giving out to different team members, this meaning the program can be written faster. The programs that do not use modules are likely to be very large and hard to understand. In procedural programming you write the code like a set of instructions a modular design will break down the procedures into simple steps and then turned into machine code easily. An example of modular elements in java:
As you can see in the example code i have set some variables at the top then underneath made some modular elements. These will set a new name for the human being we are building.
As you can see in this code we are starting to build the human up from all the smaller modules we created. Then you can easily show the characteristics in a println.
D1
Suitability of Procedural Languages for Graphical Applications.
Procedural Programming is not mostly suitable for graphical applications because while its still a step based programming language it has some advantages for example. You can show the results in a graphical box rather than just a System.out.println and mostly others like that. The example of showing procedural programming with graphical interface.
This shows the phrase "Hello user" + what you are due in dialog box rather than just printing in the event log.
Procedural programming is not the most effective for Graphical Applications. You want to be looking into Event driven code this is built for GUI's and is most suitable. Event Driven Programming uses user commands of peripherals and takes in the information effectively and displays the results back to the user, Procedural is just a step based programming language you can not input stuff into Procedural.
Procedural programming is not the most effective for Graphical Applications. You want to be looking into Event driven code this is built for GUI's and is most suitable. Event Driven Programming uses user commands of peripherals and takes in the information effectively and displays the results back to the user, Procedural is just a step based programming language you can not input stuff into Procedural.
No comments:
Post a Comment