Unit 5 - Compiles And Run Program

Posted on Saturday, May 8, 2010 by B[H] | 0 comments
Labels:

To run a C++ program, we must first create it, then compile it, then link it with other modules ( or other compiled programs), and finally run it. You can create a C++ program using the C++ editor. The editor is like a word processor that allows you to
type, edit and save your program. The program you create is called the source module.


After you have created the source program, you compiled it using the C++ compiler. The compiler translates your C++ instructions into a machine-readable form. The compiled program is called the object module.
Besides compiling the source module into an object module, the compiler also generates information necessary for linker. The linker links the object module generated by the compiler and any other object modules, your program may request into a final executable module.


Photobucket

Unit 5 - Repetition (or Iteration) structure

Posted on by B[H] | 0 comments
Labels:

The repetition (or iteration) structure permits a sequence of the instructions to be executed repeatedly until certain condition is reached. The repetition structure or loop in C++ comes in three forms while, do-while and for.

a) The while loop

The while loop repeats the body of the loop as long as the loop condition holds. The basic form of the while statement is as below:

while (expression) statement;



In this loop, the expression is first evaluated. If it is true (not zero), the statement (which can be a block is executed; if it is (zero), the statement is bypassed.


Photobucket

Photobucket





b) The do-while loop


The do-while loop executes a statement as long as the loop condition holds. The basic form of the do-while statement as below:

Do
statement
while (expression) ;



This do-while loop is quite similar to the while loop except that the expression is evaluated after the statement is executed. This means the statement in the do-while will be executed at least once. In the while statement, the statement will not be executed if the expression is false.

Photobucket

Photobucket



c) The for Loop

The for loop repeats the body of the loop as long as the loop condition holds. The basic form of the for loop as below:

for (initialization; condition test; incrementation)
{
statements;
}


• The initialization part typically refers to the initial value (if any) given to a loop variable or counter. But it can also include the initialization of any other variable. This initialization part is carried out just once at the beginning of the loop.
• The expression part determines whether the loop execution should be continued. If the expression is zero (false), the for loop is terminated, if it is not zero (true), the for statement is executed.
• The incrementation part typically increments (or decrements) the loop counter variable. This is done after the for statement is executed. This part, like the initialization part, can also include the incrementation of other variables.

Photobucket

The example 5.9, given is a very short program and it is easy for us to understand the for loop.
First, an integer variable is declared. Then, in the initialization part, the variable, iNum is set to 1. For the condition checking, iNum is checked to see whether it is equal to or less than 10. In each cycle of the loop, iNum is incremented by 1. Once iNum reaches 10, the loop exits. We can see that the program calculates the square of the first ten natural numbers.

Program output:

1 4 9 16 25 36 49 64 81 100

Unit 5 - Logical Structures And Basic Instructions (statement)

Posted on by B[H] | 0 comments
Labels:

C++ has a set of rich and powerful control structures (statements) that makes it a popular language. Control structure generally fall into four categories but in this unit we have to know only three of them, which are:

i. sequence structure
ii. selection structure
iii. repetition or iteration structure



a-Sequence structure

The sequence control structure is the simplest of all the structures. The program instructions are executed one by one, starting from the first instruction and ending in the last instruction as in the program segment.


Photobucket



b-Selection Structure

The selection structure allows to be executed non-sequentially. It allows the comparison of two expressions, and based on the comparison, to select a certain course of action. In C++ , there are three types of selection statements. They are:
i. if statement
ii. if-else statement
iii. Switch statement.

i. if Statement

The basic form of the if statement is:

If (expression) statement


In this form, the expression is first evaluated. If the expression evaluates to non-zero (meaning TRUE), the statement is executed; if it evaluates to zero (meaning FALSE), the statement following the if statement is executed. Again, it has one entry point and one exit point.

Photobucket

Photobucket



ii. if – else statement

The basic form of the if-else statement is :

Photobucket

In this form, the expression is first evaluated. If it evaluates to non-zero, statement_1 is executed, otherwise (i.e, if it evaluates to zero) statement_2 is executed. The execution of the statements are mutually exclusive, meaning, either statement_1 is executed or statement_2, but not both. The statement can, of course, take the form of blocks.

Photobucket

Photobucket

The if – else statement in the Example5.4 is to checks the value of iNum to be not equals to zero and also that the modulus value of the variable iNum is equal to zero. If condition is true, then the message ‘Even Number’ is printed on the screen. If condition is not true, then the message ‘Odd Number or Number is 0’ is printed on screen.



iii-Switch statement

The switch statement is the multiple branch decision statement is sometimes called the multiple-choice statement. The general form of the switch statement is :

Photobucket

The expression evaluates to an integer or character constants and statement sequence is a block of statements.

Photobucket

example:

Photobucket

The sample output of the program:

Please key in grade (A-F) : C
Minimun marks is 40

In the example above, A,B,C and D are the possible values that can be assigned to the variable cGrade.
In each case of the constants, A to D, a statement or sequence of statements would be executed.



You would have noticed that every line has statement under it called “break”. The break is the only thing that stops a case statement from continuing all the way down through each case label under it. In fact, if you do not put break in, the program will keep going down in the case statements, into other case labels, until it reaches the end of a break.
However, the default part is the codes that would be executed if there were no matching case of constant’s values.

Unit 5 - Introduction To Logical Structure

Posted on by B[H] | 0 comments
Labels:

Logical structure or program control structures refer to the order of execution of instructions in a program. So far, in all our examples, the instructions were executed sequentially one by one, from the top downwards. However, most real life problems require some kind of decision making, which involves comparing values, and based on the comparison, to take a certain course of action. Hence, C++ provides structure that will allow the non-sequential execution of program instructions. This means that an instruction or a whole block of instructions can be executed, repeated or skipped.

Unit 5 - Logical Structures And Basic Instructions

Posted on by B[H] | 0 comments
Labels:

General Objective : To Understand the logical structure types and basic instruction
refers to the order of execution of instructions in program.

Specific Objectives : At the end of the unit you will be able to :

- describe the sequence structure
- describe the selection structure
- describe the Repetition structure
- explain the program control structures
- write the simple program using program control structure

Unit 4 - The Expression

Posted on Friday, May 7, 2010 by B[H] | 0 comments
Labels:

Expression in C++ are formed by properly combining operators, variables and constants. We have already seen some examples of simple arithmetic and logical expression. As algebra, C++ expression can be complex. Parentheses can be used to force the order of evaluation. An expression may also contain spaces for readability.
Examples of expressions.

Gross_pay – deductions
(basic_pay + hours * rate) – (socso + premium + loan)
(b * b – 4 * a * c) > 0
(gender = = ‘m’) && (age > 20)
(gender = = ‘m’ || gender = = ‘f’ ) && age >= 21

Unit 4 - The Operators

Posted on by B[H] | 0 comments
Labels:

C++ is very rich in built-in operators. Operators trigger some computations when applied to operands in an expression. There are several general classes of operators. But for now, we will present just the arithmetic, relational, logical and assignment operators.

a-Arithmetic Operators

There are seven arithmetic operators in C++:-

Photobucket

Examples of operation involving integer variables. With a=7 and b=2, the expression on the values on the right.

Photobucket

Note: You can assign a positive or negative number to a variable by using a unary +

or - . Example:
a = -20 // assigns ‘a’ a negative 20
b = +20 // assigns ‘b’ a positive 20 ( + sign normally not needed)

Unary operators operate on single value. Thus the size of operator is a unary operator. So are the decrement and increment operator.



b-Relational Operators

There are six relational operators and three logical operators in C++:-

Photobucket

The result of evaluation of a relational operation is either true(represented by 1) or false (represented by 0). For example, if a = 7 and b = 5, then a



c-Logical Operators

There are three logical operators in C++:

Photobucket

*Hierarchy of Operators
The hierarchy of operator precedence form highest to lowest is summarized below:

Photobucket

Unit 4 - Declaring Variables

Posted on by B[H] | 0 comments
Labels:

All variables in a program must be declared prior to their use. The declaration takes the form:

Photobucket

Examples of variable declarations.

Int x, y, z;
Short small_number;
Long big_number;
Unsigned positive_number;
Char ch;
Float amount, rate;

Variables may be initialized by assigning constants to them either at the time of their declaration or at a later time.


Example of variable initialization and declaration

int m, n=10;
float rate, total = 0.0;
char response= ’n’;
char color{6}=’green’;

Unit 4 - Declaring Constant

Posted on by B[H] | 0 comments
Labels:

Constant are values that do not change during program execution. They can be of type integer, character or floating point. To declare a constant, use the keyword const as in the example:-

Photobucket

a-Integer constant

Integer constant can be further categorized into four types-short integer, integer,unsigned integer and long integer.
Examples of integer constants

• Short integer constant:
-99 -35 0 45 320

• Integer constants:
9999 -1 0 555 32767

• Unsigned integer constants:
1 256 1000 60000

• Long integer constants:
222 0 33333 9999999

A constant can also be identified as being long by tagging a l or a L to the end of the number, For example , the constants 212L and 323l. will be viewed by C++ as long constants.



b-Character and string Constants

A character constant is any character enclosed between two single quotation marks (‘ and ‘ ). When the several characters are enclosed between two double quotation marks (‘ and ‘ ), it is called a string. Examples of character and string constants;

i. Character constants:
‘$’ ‘*’ ‘ ‘ ‘z’ ‘G’

ii. String constants:
“Name:” “Telephone No:” “Postcode:”

iii. Floating Point Constants
A floating point constant is a decimal number that contains the decimal point (.) or the exponent ( e or E ) or both. Here are some examples of floating point constants.
5.0 0.005 2000.0 987.123 5e-3 0.01e-2 0.2345E8 1.23E4

Unit 4 - Floating Point data types - float and double

Posted on by B[H] | 0 comments
Labels:

This type can store floating point in computer memory.

Syntax : double name_identifier
Example: double pendapatan_bersih,cukai_pendapatan;
double nilai;

Memory storage that use for variable pendapatan_bersih be able to store floating point data. But int and char data types only can be stored according to computer types. The three floating points data in C++ such as;

1. float
2. double
3. long double


The comparison of the three types are range value and digits.

Float : 1.175494e-38 to 3.402823e+38 (6 place decimal )
Double : 2.225074e308 to 1.797693e+308 (15 place decimal)
Long double : 3.362103e-4932 to 1.189731e+4932 (19 place dec.)

Unit - Character data types ( char )

Posted on by B[H] | 0 comments
Labels:

Storage word char is use to declare variable character.

Syantax char name_identifier
example: char huruf;
char lagi;


This declaration means that variable lagi and huruf will given a memory storage for character data type. Character variable store printed data or un printed data in character set of computer includes;
• small and capital letters
• decimal digits (0-9)
• special character

This character represent in 1 byte (8 bit) computer memory. Internal representative for character value decided by encoder character (ASCII or EBCDIC) that is used in the computer.

Unit 4 - Integer data types ( int )

Posted on by B[H] | 0 comments
Labels:

Key words int is use to declare variable integer number

Syntax int name_identifier
example : int bilangan ;
int nom1,nom2;

This declaration means that the compiler was asked to hold integer data name bilangan, nom1 and nom 2. Integer data types is classified as sign (+) and unsigned (-).For all the computer system, data integer is refer to 0 and 1 bits. There are three types of integer short int, int, long int. The comparison of this integer range in value.

Short int : -32768 to 32767
Int : -32768 to 32767
Long int : -2147483648 to 2147483648
Unsigned short int: 65535
Unsigned int: 65535
Unsigned long int : 4294967295

Unit - Basic Data Types

Posted on by B[H] | 0 comments
Labels:

There are four main data types in programming C++ :-

i. int
ii. char
iii. double
iv. float

For additional of basic data types programming C++ can support another built-in data types such as short, long, signed and unsigned. The various data types, the number of bits required to store them.

Photobucket

Unit 4 - INTRODUCTION TO DATA TYPES, OPERATOR AND EXPRESSION IN C++

Posted on by B[H] | 0 comments
Labels:

The C++ character set includes the keyboard characters, namely the uppercase letter A - Z, the lower letters a – z , the digits 0 – 9 , and other special characters (such as!, #, [, ] , ,&,<,?, and * ). The blank space is also a character in the set.
Identifiers are simply references to memory location which can hold values. They are formed by combining letters (both upper and lowercase), digits and the underscore( _ ). The first character of an identifier, however, must be a letter. The blank character is not permitted in an identifier. Although identifiers can be formed by freely combining the letters, digits and underscores, common sense tells us that
we should give them suggestive names, that is, names that reflect the data items that they are going to store. Identifiers can be of any length although in practice they seldom exceed 25 characters.

Example of valid and invalid identifiers:

Photobucket

C++ identifiers are case-sensitive, meaning, lower and uppercase letter in identifiers are treated as different characters. This means we cannot freely mix the lower and uppercase letter to refer to the same identifier. For example, identifiers HOURLY_RATE, Hourly_Rate, Hourly_rate and hourly_rate are all different, they refer to different memory locations.
Variables are identifiers whose value may change during the course of execution of a program.
Keywords in C++, also called reserved words, have standard, predefined meanings and must be used only for their intended purpose. Programmers therefore should not use these keywords as identifiers.

Unit 4 - Data Types, Operator And Expression

Posted on by B[H] | 0 comments
Labels:

General Objective : To Introduce and Use the data types, operator and
expression in C++ Programming.


Specific Objectives : At the end of the unit you will be able to :

- describe the essential data type : int,char,float and double
- declare constant and variable
- able to use constant and variable
- explain the arithmetic operator types
- explain the arithmetic, relational and logical operator types
- able to used operators to construct expression

Unit 3 - Key Facts

Posted on by B[H] | 0 comments
Labels:

1. The algorithm should be tested at the flowchart stage before being coded
into a program.
2. Pseudocode, flowcharts and structure charts are universal problem solving tools that can be used to construct program in any computer language
3. Flowcharts are used to provide visualization of the flow of certain programming tasks

Unit 3 - Class Average Flowchart

Posted on by B[H] | 0 comments
Labels:

Photobucket

Unit 3 - Using Algorithm and Flowchart in programming

Posted on by B[H] | 0 comments
Labels:

Class average Algorithm

Problem: Calculate and report the grade-point average for a class.

Discussion: The average grade equals the sum of all grades divided by number of students. We need a loop to read and then add (accumulate) the grades for each student in the class. Inside the loop, we also need to total (count) the number of students in the class.

Input: Students grades

Processing: Find the sum of the grades; count the number of students; calculate average grades = sum of grades / number of students.

Output: Average grade.

Unit 3 - Structure Chart

Posted on by B[H] | 0 comments
Labels:

Structure chart is also known as input-process-output or hierarchy chart shows the overall program structure. It refers to planning diagrams similar to a

company’s organization chart. Structure chart depicts the organization of program but omit the specific processing logic. They describe what each part, or module, of the program does and they show how the modules relate to each other. Each module may be subdivided into succession of sub-modules that branch out under it. The charts are read from top to bottom and left to right. Figures 3.3 shows an example of a structure chart. This price of discount item problem was solved by a series of instructions to read data, perform calculations, and display results. Each steps was in sequence; that is we moved from one line to the next without skipping over any lines.

The main benefit of structure charts is in the initial planning program. We break down the major parts of a program so we can see what must be done in general. From this point, we can then refine each module into more detailed plans using flowcharts.

Photobucket

Unit 3 - Pseudocode

Posted on by B[H] | 0 comments
Labels:

Pseudocode is an abbreviated version of actual computer code. The geometric symbols used in flowcharts are replaced by English-like statements that outline the process. Pseudocode looks more like computer code than does flowchart. It allows programmer to focus on the steps required to solve a problem rather than on how to use computer language.

The programmer can describe the algorithm in computer language form without being restricted by the rules of the computer language. When the pseudocode is completed it can be easily translated into any computer language.
The following is pseudocode for the price of discount sales item problem:

Program: determine the price of discount item on sale.
Read price (Input)
Set the value of discount = rate of discount * price entered (Process)
price of discount item = price of item - value of discount (Process)
Display the price after discount (Output)

Pseudocode has several advantages. It is compact and probably will not extend for many pages as flowcharts commonly do. Also the plan looks like the code to be written and preferred by many programmers.

Unit 3 - Flowcharts

Posted on by B[H] | 0 comments
Labels:

Graphic representation of algorithm is known as flowchart which consist of geometric symbols. These symbols are connected by line of arrows called flowlines which indicate the direction of flow of processes or activities. The shape of the symbol indicates the type of operation that is to occur. Flowchart should flow from the top of the page to the bottom. The symbols used in flowchart are standardized.

Photobucket
Photobucket

The main advantage of using a flowchart to plan a task is that it provides a pictorial representation of the task, which makes the logic easier to follow. We can clearly see each and every step and how it is connected to the next step. For example lets look at the discount sales program.

Photobucket

The major disadvantage with flowcharts is that when a program is very large, the flowcharts may continue for many pages, making them difficult to follow and modify.

Unit 3 - Algorithm (Algorithma)

Posted on by B[H] | 0 comments
Labels:

The techniques of selecting program statements and their logical sequencing which emphasize the translating of each step of program outline into one or equivalent C++ instruction is known by algorithm. Every detail, including obvious steps , should appear in algorithm.
You use algorithm everyday to make decisions or perform tasks. For example, a 30% discount sales at the supermarket, you must be able to write program that calculate and display the price of item after discount according to the price entered by consumer:-

i. Request price of item (Input)
ii. Value of discount = rate of discount * price (Process)
iii. Price after discount = price - value of discount (Process)
iv. Display of discount price (Output)

Unit 3 - Introduction The Technique To Develope C++ Programming

Posted on by B[H] | 0 comments
Labels:

The first step in writing instructions to carry out a task is to determine what the output should be – that is, what the task should produce. The second step is to identify the data, or input, necessary to obtain the output. The last step is to determine how to process the input to obtain the desired output. The general process of writing program is to analyze the problem, design and plan the solution, coding


which is to translate the algorithm into a programming language and finally testing and debugging.
In this unit we shall discuss the logical sequence of precise steps that solve the problem known as algorithm and three popular programming tools or techniques used to develop the logic plan: flowcharts, pseudo code and structure chart or input-process-output chart.

Unit 3 - Introduction To The Concept And Basic Instruction Of Programming C++

Posted on by B[H] | 0 comments
Labels:

General Objective : To introduce techniques used in program design.

Specific Objectives : At the end of the unit you will be able to :

- state the techniques of program designing tools
- briefly explain the techniques of designing program by different designing tools
- use algorithm and flowchart to develop computer program


**A recipe provides good and simple example of a plan. The ingredients and the amounts are determined by what is to be baked. That is the output determines the input and processing. The recipe or plan reduces the number of mistakes you might make. Many programmers particularly beginners frequently try to write without first making a careful plan. Step-by step process will enable you to use your time efficiently and help you design error free program that produced the desired output.**

Unit 2 - Basic Input, Output and Format Code

Posted on by B[H] | 0 comments
Labels:

In the iostream C++ library, standard input and output operations for a program are supported by two data streams:

a. cin (console input) for input – normally assigned to the keyboard
b. cout (console input) for output – normally directed to the screen.

By handling these two streams you will be able to interact with the user in your programs since you will be able to show messages in the screen and to receive his/her input from the keyboard.

1- Output (cout )

The function cout is used with the overloaded operator << (a pair of “less than” signs). It follows the following format as in the following examples: Photobucket

2.Input ( cin )

Handling the standard input in C++ is done by applying the overloaded operator of extraction ( >> ) on the cin stream, followed by the variable that will store the data that is going to be read. It follows the following format:
Photobucket


3-Format Code ( Backslash Character Constant)

The backslash character constant is also known as the ‘Escape Sequence’. Certain characters such as the backspace and carriage return are not printable characters and these characters pose special problems when printing using text editor. The backslash character constant is used together with other character constant when such problems are encountered.

Photobucket

Photobucket

This example shows the use of the new line (\n) character constant to print characters on the next line.

Unit 2 - C ++ Program Characteristics

Posted on by B[H] | 0 comments
Labels:

Let us examine the program in detail. C++ program is made of a few components. They are:

1-Comments

Comments are used to insert remarks into the source code help to explain about what the program does. In C++, comments can be place anywhere in the programs. It can be used to include the details of the project and the programmer who wrote or modified the code.
There are two types of comment used. They are:

a. Multi-line Comment

This type of comment is begins with a /* (slash followed by an asterisk) symbol and ended with a */ (asterisk followed by an slash) symbol.

This type of comment is good to be used when comments written are longer than 1 line.

Example:
/* This is a program that computes the sum of two integer
numbers */



b. Single line Comment

This type of comment is used with the // (double slash) symbol and it stops at the end of that particular line.
This type of comment can be used when the remark is only 1 line in length.

Example:

// This is a preprocessor



2- Header Files

Header files contain information that is required to run a program. It is a pre written and tested function that comes together with the compiler and is available for the use of the programmers. The format or structure for using the header file is by using the #include directive. The second line in our program 2.1 #include is called an include preprocessor directive. As the file is placed before program the program proper , it is called a header file (with the file extension .h)

Example :
Photobucket



3-Functions

A function is a block of statements that is part of a large programme.

a. Function main( )

A C++ program must have at least the function main( ). Every C++ function, including main( ), must have a body enclosed in braces { }.

b. Function block { }

The function body, also called block can be of any size. The function always ends with the return command.

{ - begin block

} - end block


Example:

main ( )
{

}

Unit 2 - Introduction to C++ program

Posted on by B[H] | 0 comments
Labels:

Getting Started : Example of C++ program


To make C++ work for you, you must be able to write C++ program. To give C++ instructions to a computer, you will need and editor and a C++ compiler. An editor lets you type a C++ program, make changes and save it in a file. The compiler then translate your C++ program into a form that your computer can read. Then finally, you will be able to run your program.
To get started, we introduce in this chapter a simple C++ program and then go on to briefly explain the various parts that make up a C++ program.





Unit 2 - Introduction To The Concept And Basic Instruction Of Programming C++

Posted on by B[H] | 0 comments
Labels:

General Objective : To know the characteristics and using instructions of
C++ program basic language

Specific Objectives : At the end of the unit you will be able to :

- state what is the header file.

- state what is the statement ‘main ( )’.

- state and write comment line using backslash symbol

- define the function of input and output statement

Unit 1 - Activity 1B

Posted on by B[H] | 0 comments
Labels:

TEST YOUR UNDERSTANDING BEFORE YOU CONTINUE WITH THE NEXT INPUT…!


1. State the steps in developing program.

2. State the components of documenting a program.

3. What is a flowchart?





Feedback To Activity 1B


1. i Defining and analyzing problems
ii Planning of variables
iii Drawing of flowchart
iv Program writing
v Testing and debugging program
vi Documentation of program.

2. i An accurate specification of requirement
ii Detail input, output, constraint and formula for the above problems
iii Algorithm in the form of flowchart or pseudo code
iv Program source complete with comment
v Sample program which had been run and executed and the tested data.
vi Guideline on how to use the program.

3. Flowchart represents algorithm in graphic form comprising of geometrical
symbols which is interrelated by line of flow.

Unit 1 - Documentation of program

Posted on by B[H] | 0 comments
Labels:

Program must be documented for future references and maintenance process. A well documented program will make it easier for the original programmer or other programmer to follow the program logic and design. Program document should consist of :-

1. An accurate specification of requirement
2. Detail input, output, constraint and formula for the above problems
3. Algorithm in the form of flowchart or pseudocode
4. Program source complete with comment
5. Sample program which had been run and executed and the tested data.
6. Guideline on how to use the program.

Unit 1 - Testing and debugging program

Posted on by B[H] | 0 comments
Labels:

Once the program has been written it must be compiled and executed. This is accomplished by an editor and compiler. An editor lets us type a program, makes changes and save it to a file. The compiler then translates the program into a form that the computer can read. Once the program has been compiled and executed the presence of errors will be readily apparent. Syntactic and execution errors usually result in the generation of error when compiling or executing a program. Error of this type is usually quite easy to find and correct. Much more difficult to detect are logical errors since the output resulting from logically incorrect program may appear to be error free. Thus a good bit of probing may be required which is known as logical debugging.

Unit 1 - Program writing

Posted on by B[H] | 0 comments
Labels:

In the design of program it should be written as simple as possible. The main objective is to give a clear, readable programs through an orderly and disciplined approach to programming.

Unit 1 - Drawing of Flowchart

Posted on by B[H] | 0 comments
Labels:

Flowchart represents algorithm in graphic form comprising of geometrical symbols which is interrelated by line of flow.

Unit 1 - Drawing of Flowchart

Posted on by B[H] | 0 comments
Labels:

Flowchart represents algorithm in graphic form comprising of geometrical symbols which is interrelated by line of flow.

Unit 1 - Planning of variables

Posted on by B[H] | 0 comments
Labels:

Variables are simply references to memory locations. A well plan use
of variables will produce an efficient execution of program in terms
of speed and memory utilization.

Unit 1 - Defining and analyzing problems

Posted on by B[H] | 0 comments
Labels:

Programming begin with a specification of problems. This steps is to identify and understand what are the problems to resolve. The problems must be clearly define, explicit and the requirements in resolving it. Analyzing the problems will determine the input, output and information required to solve these problems, as follows:-

a. input – data to be processed
b. output – the desired result
c. the constraint and additional features in resolving the problems

Unit - Identifying steps in programming

Posted on by B[H] | 0 comments
Labels:

In solving problems of developing program, software development method is used. It consists of several steps which is known as software life cycle, these are:-

1. Defining and analyzing problems
2. Planning of variables
3. Drawing of flowchart
4. Program writing
5. Testing and debugging program
6. Documentation of program.

Process of designing program can be divided into two phases mainly the problem solving phase and implementation phase. The problem solving phase consist of steps 1 through 3 and implementation phase involved steps 4 and 5. While in step 6, documentation is done throughout the process of designing program..

Unit 1 - Activity 1A

Posted on by B[H] | 0 comments
Labels:

TEST YOUR UNDERSTANDING BEFORE YOU CONTINUE WITH THE NEXT INPUT…!


1.1- List the characteristics of a well planned program.

1.2 -What is a program?


1.3 -State the difference between batch mode and interactive mode operation.





Feedback To Activity 1A

1.1 -Integrity, Clarity, Simplicity, Efficiency, Modularity, Generality.

1.2 -A set of instructions that tells the computer what to do is called a program.

1.3 -In batch mode of operation, the program and the data are typed into the computer
and stored within computer’s memory and processed in its proper sequence.
Large quantities of information can be transmitted into and out of the computer
without the user present while the job being processed. Batch processing can be
undesirable for simple jobs. In interactive mode the user and the computer are
able to interact with each other during computational session.

Unit 1 - The components of program structure.

Posted on by B[H] | 0 comments
Labels:

1. Declaration
A declarations associates a group of variables with a specific data type. All variables must be declared before they can appear in excutable statements.
Example :
int a, b, c;
float root1, root2;
char flag, text[80]

2. Input
A set of information called data will be entered into the computer from keyboard, floppy disk, hard disk etc. and stored in a portion of the computer memory. This input which is an input to the computer will then be processed to produced the desired result.

3. Storage
Every piece of information are stored within the computer’s memory which is encoded as some unique combination of zeros and ones. Small computers have memories that are organized into 8-bit multiples called bytes. Large computer have memories that are organized into words rather than bytes. Computers also employ auxiliary storage e.g. disks in addition to their primary memories

which allowed information to be stored permanently and can be physically disconnected when not in use.

4. Operation
There are two different ways computer can be utilized by many different users. These are batch mode and the interactive mode. In batch mode of operation the program and the data are typed into the computer and stored within computer’s memory and processed in its proper sequence. Large quantities of information can be transmitted into and out of the computer without the user present while the job being processed. Batch processing can be undesirable for simple jobs. In interactive mode the user and the computer are able to interact with each other during computational session.

5. Control
Program control refers to the order of execution of instructions in a program. The instruction can be executed sequentially – one by one, from top downwards or non sequential execution of program instruction. Most real life problems require some kind of decision making to take a certain course of action. This means that instruction or a whole block of instructions can be executed, repeated or skipped.

6. Output
The processed data which produced certain result is known as the output. The output data will be presented in a sheet of paper through the printer or display on a monitor.

Unit 1 - Definition of program

Posted on by B[H] | 0 comments
Labels:

A set of instructions that tells the computer what to do is called a program. For example, a word processor is a program written in computer language like C++, that tells the computer what to do when you type in a letter.

UNIT 1 - Basic concept of Programming

Posted on by B[H] | 0 comments
Labels:

Before we start writing our own programs let us examine some important characteristics of well-written computer programs. Basically these apply to any programming language that provide a useful set of guidelines.

a. Integrity. This refer to the accuracy of the calculations since it will be meaningless if calculations are not carried out correctly.

b. Clarity. This refer to the overall readability of the program, with particular emphasis on its underlying logic. If a program is clearly written, it should be possible for programmer to follow the program logic with ease.

c. Simplicity. The clarity and accuracy of a program are usually enhanced by keeping things as simple as possible, consistent with the overall program objectives.

d. Efficiency. This is concerned with execution speed and efficient memory utilization.

e. Modularity. Many programs can be broken down into a series of identifiable subtask that enhances accuracy and clarity of a program and facilitates future program alterations.

f. Generality. Usually we will want a program to be as general as possible, within reasonable limits. A considerable amount of generality can be obtained with very little additional programming effort.