CMP 101 Introduction To Computer Science
CMP 101 Introduction To Computer Science
CMP 101 Introduction To Computer Science
OBJECTIVES
The specific objectives of this course are to:
1. Understand the history, classification and impact of computers.
2. Know the concept of computer hardware and software.
3. Understand features of a good program.
4. Understand the concept of Algorithms and flowcharting.
5. Understand the principles of designing algorithms for common programming problem.
6. Understand the concept of debugging and maintaining program.
LEARNING OUTCOMES
The students should be able to:
1. Define computer
2. Know the history, classification and computer applications
3. Know the concept of computer hardware
4. Know the concept of computer software.
5. Know the data preparation methods
6. Know the Characteristics of a Computer.
7. Know features of a good program.
8. Explain the concept of Computer problem solving techniques, Algorithms and
flowcharting.
9. Explain General modular program design principles.
10. Explain expressions and control structure.
11. Explain the procedure in solving programming problems.
12. Explain the concept of debugging and maintaining program.
13. Know the FORTRAN basic syntax.
14. Know the various data types in FORTRAN
15. Know how to declare variables and constants in FORTRAN
16. Know the different operators and precedence in FORTRAN
17. Know the different structured constructs in FORTRAN
18. Know character declaration and operations in FORTRAN
19. Know string declaration and operations in FORTRAN
20. Know Array declarations and operations in FORTRAN
21. Know the declaration of a pointer variable in FORTRAN
22. Know programming style in FORTRAN
23. Know how to debug programs in FORTRAN.
TEXT BOOK(S):
1. Goel, A. (2010). Computer fundamentals. Pearson Education India.
2. Chivers, I. D., & Sleightholme, J. (2018). Introduction to programming with Fortran
(Vol. 2). Cham: Springer.
3. Metcalf, M., Reid, J. K., & Cohen, M. (2004). Fortran 95/2003 Explained (Vol. 3).
Oxford: Oxford University Press.
4. Chapman, S. J., & Chapman, S. J. (2008). Fortran 95/2003 for scientists and engineers
(Vol. 974). Boston: McGraw-Hill.
CHARACTERISTICS OF A COMPUTER
The characteristics of the computer system are as follows –
LESSON 2
COMPONENTS OF COMPUTER SYSTEM
Computer systems consist of three components as shown in below image: Central Processing
Unit, Input devices and Output devices. Input devices provide data input to processor, which
processes data and generates useful information that’s displayed to the user through output
devices. This is stored in computer’s memory.
Central Processing Unit
The Central Processing Unit (CPU) is called “the brain of computer” as it controls operation
of all parts of computer. It consists of two components: Arithmetic Logic Unit (ALU), and
Control Unit.
Figure 3: Components of Computer System
KEYBOARD
Keyboard is the most common and very popular input device which helps to input data to the
computer. The layout of the keyboard is like that of traditional typewriter, although there are
some additional keys provided for performing additional functions.
Keyboards are of two sizes 84 keys or 101/102 keys, but now keyboards with 104 keys or 108
keys are also available for Windows and Internet.
The keys on the keyboard are as follows:
S/N Keys Description
These keys include the letter keys (A-Z) and digit keys (0-
1 Typing Keys 9) which generally give the same layout as that of
typewriters.
It is used to enter the numeric data or cursor movement.
Generally, it consists of a set of 17 keys that are laid out
2 Numeric Keypad
in the same configuration used by most adding machines
and calculators.
The twelve function keys are present on the keyboard
which are arranged in a row at the top of the keyboard.
3 Function Keys
Each function key has a unique meaning and is used for
some specific purpose.
These keys provide cursor and screen control. It includes
four directional arrow keys. Control keys also include
4 Control keys
Home, End, Insert, Delete, Page Up, Page Down,
Control(Ctrl), Alternate(Alt), Escape(Esc).
Keyboard also contains some special purpose keys such as
Special Purpose
5 Enter, Shift, Caps Lock, Num Lock, Space bar, Tab, and
Keys
Print Screen.
Output Devices
Output device Characteristic
Monitor A monitor is most common type of output device.
It is also called as “Visual Display Unit”.
The inputs given by keyboard or any other input devices will
get displayed on monitor.
Cathode Ray Tube (CRT) and Flat panel display monitors are
commonly used monitors.
Printers Printers are most common type of output devices which are
used to take a hard copy of any digital document.
The two types of printers are impact and non-impact printers.
Non-impact printers such as laser and inkjet printers are less
noisy, more reliable and faster and also offer high quality
compared to impact printers.
Sound Systems Sound systems are output devices which are used to get
multimedia content such as voice, music, etc., as output. Some
of examples of sound systems are speakers, headphones, and
microphones.
PRINTERS
Printer is an output device, which is used to print information on paper.
There are two types of printers:
Impact Printers
Non-Impact Printers
Impact Printers
Impact printers print the characters by striking them on the ribbon, which is then pressed on
the paper.
Characteristics of Impact Printers are the following:
Very low consumable costs
Very noisy
Useful for bulk printing due to low cost
There is physical contact with the paper to produce an image
These printers are of two types -
1. Character printers
2. Line printers
Character Printers
Character printers are the printers which print one character at a time.
These are further divided into two types:
Dot Matrix Printer (DMP)
Daisy Wheel
Dot Matrix Printer
In the market, one of the most popular printers is Dot Matrix Printer. These printers are popular
because of their ease of printing and economical price. Each character printed is in the form of
pattern of dots and head consists of a Matrix of Pins of size (5*7, 7*9, 9*7 or 9*9) which come
out to form a character which is why it is called Dot Matrix Printer.
Advantages
Inexpensive
Widely Used
Other language characters can be printed
Disadvantages
Slow Speed
Poor Quality
Daisy Wheel
Head is lying on a wheel and pins corresponding to characters are like petals of Daisy (flower)
which is why it is called Daisy Wheel Printer. These printers are generally used for word-
processing in offices that require a few letters to be sent here and there with very nice quality.
Advantages
More reliable than DMP
Better quality
Fonts of character can be easily changed
Disadvantages
Slower than DMP
Noisy
More expensive than DMP
Line Printers
Line printers are the printers which print one line at a time.
These are of two types -
Drum Printer
Chain Printer
Drum Printer
This printer is like a drum in shape hence it is called drum printer. The surface of the drum is
divided into a number of tracks. Total tracks are equal to the size of the paper, i.e. for a paper
width of 132 characters, drum will have 132 tracks. A character set is embossed on the track.
Different character sets available in the market are 48 character set, 64 and 96 characters set.
One rotation of drum prints one line. Drum printers are fast in speed and can print 300 to 2000
lines per minute.
Advantages
Very high speed
Disadvantages
Very expensive
Characters fonts cannot be changed
Chain Printer
In this printer, a chain of character sets is used, hence it is called Chain Printer. A standard
character set may have 48, 64, or 96 characters.
Advantages
Character fonts can easily be changed.
Different languages can be used with the same printer.
Disadvantages
Noisy
Non-impact Printers
Non-impact printers print the characters without using the ribbon. These printers print a
complete page at a time, thus they are also called as Page Printers.
These printers are of two types -
Laser Printers
Inkjet Printers
Characteristics of Non-impact Printers
Faster than impact printers
They are not noisy
High quality
Supports many fonts and different character size
Laser Printers
These are non-impact page printers. They use laser lights to produce the dots needed to form
the characters to be printed on a page.
Advantages
Very high speed
Very high quality output
Good graphics quality
Supports many fonts and different character size
Disadvantages
Expensive
Cannot be used to produce multiple copies of a document in a single printing
Inkjet Printers
Inkjet printers are non-impact character printers based on a relatively new technology. They
print characters by spraying small drops of ink onto paper. Inkjet printers produce high quality
output with presentable features.
They make less noise because no hammering is done and these have many styles of printing
modes available. Colour printing is also possible. Some models of Inkjet printers can produce
multiple copies of printing also.
Advantages
High quality printing
More reliable
Disadvantages
Expensive as the cost per page is high
Slow as compared to laser printer
COMPUTER MEMORY
Computer memory refers to storage area where data is stored. It is of two types:
Primary Memory
Secondary Memory
Primary Memory
Primary memory is the main memory of computer present in motherboard. Primary memory is
of two types as shown in the image below.
Random Access Memory
RAM is referred as temporary memory, in which, information stored is lost once computer is
turned off. It is a volatile memory. Instructions written in this memory can be modified; hence
it is also known as programmable memory. The two types of RAM are Static RAM (faster and
costlier) and Dynamic RAM.
Figure 5: Schematic diagram of primary memory
Secondary Memory
Sometimes when data to be processed is large, it cannot fit in primary memory as it is limited,
in such cases, we use supplement memory or secondary memory. Secondary memory helps to
store information permanently and is non-volatile. Examples of secondary storage memory are
compact disk, floppy disk, pen drive, external hard drive, etc.
CONCEPT OF HARDWARE AND SOFTWARE
The Computing System
The computing system is made up of the computer system, the user and the environment in
which the computer is operated.
The Computer System
The computer system is made up of the hardware and the software. The concept of hardware
and software is explained in detail below:
HARDWARE
The term hardware refers to mechanical device that makes up computer. Computer hardware
consists of interconnected electronic devices that we can use to control computer’s operation,
input and output. Examples of hardware are CPU, keyboard, mouse, hard disk, etc.
Hardware Components
Computer hardware is a collection of several components working together. Some parts are
essential and others are added advantages. Computer hardware is made up of CPU and
peripherals as shown in image below.
SOFTWARE
A set of instructions that drives computer to do stipulated tasks is called a program. Software
instructions are programmed in a computer language, translated into machine language, and
executed by computer. Software can be categorized into two types:
System software
Application software
System Software
System software operates directly on hardware devices of computer. It provides a platform to
run an application. It provides and supports user functionality. Examples of system software
include operating systems such as Windows, Linux, Unix, etc.
Application Software
An application software is designed for benefit of users to perform one or more tasks. Examples
of application software include Microsoft Word, Excel, PowerPoint, Oracle, etc.
Differences between Software and Hardware are sorted out below:
S/N Software Hardware
1. * It is a collection of programs to bring It includes physical components of
computer hardware system into computer system.
operation.
2. It includes numbers, alphabets, It consists of electronic components
alphanumeric symbols, identifiers, like
keywords, etc. ICs, diodes, registers, crystals, boards,
insulators, etc.
3. Software products evolve by adding Hardware design is based on
new features to existing programs to architectural decisions to make it work
support hardware. over a range of environmental
conditions and time.
4. It will vary as per computer and its It is mostly constructed for all types of
built-in functions and programming computer systems.
language.
5. It is designed and developed by The hardware can understand only low-
experienced programmers in high-level level language or machine language.
language.
6. t is represented in any high-level The hardware works only on binary
language such as BASIC, COBOL, C, codes
C++, JAVA, etc. 1’s and 0’s.
7. The software is categorized as The hardware consists of input devices,
operating system, utilities, language output devices, memory, etc.
processor, application software, etc.
Computer users
Computer users are the different categories of personnel that operates the computer. We have
expert users and casual users. The expert users could be further categorized into computer
engineers, computer programmers and computer operators.
The computing environment
The computing environment ranges from the building housing the other elements of the
computing system namely the computer and the users, the furniture, auxiliary devices such as
the voltage stabilizer, the Uninterruptible Power Supply System (UPS), the fans, the air
conditioners etc. The schematic diagram of the computing system is presented in Figure 9a to
Figure 9e.
Figure 9a: Schematic diagram of the computing system
CLASSIFICATION OF COMPUTERS
The computer has passed through many stages of evolution from the days of the mainframe
computers to the era of microcomputers. Computers have been classified based on different
criteria. In this unit, we shall classify computers based on three popular methods.
Objectives
The objectives of this unit are to:
i. Classify computers based on size, type of signal and purpose.
ii. Study the features that differentiate one class of the computer from the others.
Categories of Computers
Although there are no industry standards, computers are generally classified in the following
ways:
Classification based on signal type
Digital computer
Analogue computer
Hybrid computer
Classification by purpose
Special purpose
General purpose
Classification by capacity
Mainframe
Mini computers
Micro computers
CLASSIFICATION BASED ON SIGNAL TYPE
There are basically three types of electronic computers. These are the Digital, analogue and
Hybrid computers.
Digital Computer
Represent its variable in the form of digits. It counts the data it deals with, whether representing
numbers, letters or other symbols, are converted into binary form on input to the computer. The
data undergoes a processing after which the binary digits are converted back to alphanumeric
form for output for human use. Because of the fact that business applications like inventory
control, invoicing and payroll deal with discrete values; they are best processed with digital
computers. As a result of this, digital computers are mostly used in commercial and business
places today.
Analogue Computer
It measures rather than counts. This type of computer represents its variables in terms of
electrical voltage and sets up circuit analogue to the equation connecting the variables. The
answer can be either by using a voltmeter to read the value of the variable required, or by
feeding the voltage into a plotting device. They hold data in the form of physical variables
rather than numerical quantities.
In theory, analogue computers give an exact answer because the answer has not been
approximated to the nearest digit. Whereas, when we try to obtain the answers using a digital
voltmeter, we often find that the accuracy is less than that which could have been obtained
from an analogue computer.
It is almost never used in business systems. It is used by the scientist and engineer to solve
systems of partial differential equations. It is also used in controlling and monitoring of systems
in such areas as hydrodynamics and rocketry; in production.
Hybrid Computer
In some cases, the user may wish to obtain the output from an analogue computer as processed
by a digital computer or vice versa. To achieve this, he set up a hybrid machine where the two
are connected and the analogue computer may be regarded as a peripheral of the digital
computer. In such a situation, a hybrid system attempts to gain the advantage of both the digital
and the analogue elements in the same machine. This kind of machine is usually a special-
purpose device which is built for a specific task. It needs a conversion element which accepts
analogue inputs, and output digital value. Such converters are called digitizers. There is need
for a converter from analogue to digital also.
It has the advantage of giving real-time response on a continuous basis. Complex calculations
can be dealt with by the digital elements, thereby requiring a large memory, and giving accurate
results after programming. They are mainly used in aerospace and process control applications.
Examples are MODEM, SIM card etc.
CLASSIFICATION BY PURPOSE
Depending on their flexibility in operation, computers are classified as either special purpose
or general purpose.
Special Purpose Computers
A special purpose computer is one that is designed to solve a restricted class of problems. Such
computers may even be designed and built to handle only one job. In such machines, the steps
or operations that the computer follows may be built into the hardware. Most of the computers
used for military purposes fall into this class. Other example of special purpose computers
include:
Computers designed specifically to solve navigational problems.
Computers designed for tracking airplane or missiles.
Computers used for process control applications in industries such as oil refinery,
chemical manufacture, steel processing and power generation.
Computers used as robots in factories like vehicles assembly plants and glass industries.
Attributes of Special Purpose Computers
1. Special purpose computer are usually very efficient for the tasks for which they are
specially designed.
2. They are very much less complex than the General-Purpose Computers. The simplicity
of the circuiting stems from the fact that provision is made only for limited facilities.
3. They are very much cheaper than the General-Purpose type since they involve less
components and are less complex.
General-Purpose Computers
General-Purpose computers are computers designed to handle wide range of problems.
Theoretically, a general-purpose computer can be adequate by means of some easily alterable
instructions to handle any problems that can be solved by computation. In practice however,
there are limitations imposed by memory size, speed and the type of input/output devices.
Examples of areas where the general purpose are employed include the following:
Payroll
Banking
Billing
Sales analysis
Cost accounting
Manufacturing scheduling
Inventory control
Attributes of General-Purpose Computers
1. General-Purpose computers are more flexible than special purpose computers.
2. They can handle a wide spectrum of problems.
3. They are less efficient than the special-purpose computers due to such problems as;
4. Inadequate storage;
5. Low operating speed;
6. Coordination of the various tasks and subsection may take time.
7. General Purpose Computers are more complex than the special purpose ones.
ALGORITHM
Definition
A set of sequential steps usually written in Ordinary Language to solve a given problem is
called Algorithm.
It may be possible to solve to problem in more than one ways, resulting in more than one
algorithm. The choice of various algorithms depends on the factors like reliability, accuracy
and easy to modify. The most important factor in the choice of algorithm is the time
requirement to execute it, after writing code in High-level language with the help of a computer.
The algorithm which will need the least time when executed is considered the best.
Steps involved in algorithm development
An algorithm can be defined as “a complete, unambiguous, finite number of logical steps for
solving a specific problem “.
Step1. Identification of input: For an algorithm, there are quantities to be supplied called input
and these are fed externally. The input is to be identified first for any specified problem.
Step2: Identification of output: From an algorithm, at least one quantity is produced, called for
any specified problem.
Step3 : Identification the processing operations : All the calculations to be performed in order
to lead to output from the input are to be identified in an orderly manner.
Step4 : Processing Definiteness : The instructions composing the algorithm must be clear and
there should not be any ambiguity in them.
Step5 : Processing Finiteness : If we go through the algorithm, then for all cases, the algorithm
should terminate after a finite number of steps.
Step6 : Possessing Effectiveness : The instructions in the algorithm must be sufficiently basic
and in practice they can be carries out easily.
An algorithm must possess the following properties
1. Finiteness: An algorithm must terminate in a finite number of steps
2. Definiteness: Each step of the algorithm must be precisely and unambiguously stated
3. Effectiveness: Each step must be effective, in the sense that it should be primitive easily
convert able into program statement) can be performed exactly in a finite amount of time.
4. Generality: The algorithm must be complete in itself so that it can be used to solve problems
of a specific type for any input data.
5. Input/output: Each algorithm must take zero, one or more quantities as input data produce
one or more output values. An algorithm can be written in English like sentences or in any
standard representation sometimes, algorithm written in English like languages are called
Pseudo Code.
Example
1. Suppose we want to find the average of three numbers, the algorithm is as follows
Step 1 Read the numbers a, b, c
Step 2 Compute the sum of a, b and c
Step 3 Divide the sum by 3
Step 4 Store the result in variable d
Step 5 Print the value of d
Step 6 End of the program
2. Write an algorithm to calculate the simple interest using the formula. Simple interest = P*N*
R/100.
Where P is principle Amount, N is the number of years and R is the rate of interest.
Step 1: Read the three input quantities’ P, N and R.
Step 2 : Calculate simple interest as
Simple interest = P* N* R/100
Step 3: Print simple interest.
Step 4: Stop.
3. Area of Triangle: Write an algorithm to find the area of the triangle.
Let b, c be the sides of the triangle ABC and A the included angle between the given sides.
Step 1: Input the given elements of the triangle namely sides b, c and angle between the sides
A.
Step 2: Area = (1/2) *b*C* sin A
Step 3: Output the Area
Step 4: Stop.
4. Write an algorithm to find the largest of three numbers X, Y,Z.
Step 1: Read the numbers X,Y,Z.
Step 2: if (X > Y)
Big = X
else BIG = Y
Step 3 : if (BIG < Z)
Step 4: Big = Z
Step 5: Print the largest number i.e. Big
Step 6: Stop.
FLOW CHART
A flow chart is a step by step diagrammatic representation of the logic paths to solve a given
problem. Or A flowchart is visual or graphical representation of an algorithm.
The flowcharts are pictorial representation of the methods to be used to solve a given problem
and help a great deal to analyze the problem and plan its solution in a systematic and orderly
manner. A flowchart when translated in to a proper computer language, results in a complete
program.
Advantages of Flowcharts
1. The flowchart shows the logic of a problem displayed in pictorial fashion which felicitates
easier checking of an algorithm.
2. The Flowchart is good means of communication to other users. It is also a compact means
of recording an algorithm solution to a problem.
3. The flowchart allows the problem solver to break the problem into parts. These parts can be
connected to make master chart.
4. The flowchart is a permanent record of the solution which can be consulted at a later time.
Differences between Algorithm and Flowchart
Algorithm Flowchart
1. A method of representing the step-by-step 1. Flowchart is diagrammatic representation
logical procedure for solving a problem of an algorithm. It is constructed using
different types of boxes and symbols.
2. It contains step-by-step English 2. The flowchart employs a series of blocks
descriptions, each step representing a and arrows, each of which represents a
particular operation leading to solution of particular step in an algorithm
problem
3. These are particularly useful for small 3. These are useful for detailed
problems representations of complicated programs
4. For complex programs, algorithms prove 4. For complex programs, Flowcharts prove
to be Inadequate to be adequate
b. Input and output indicators: Parallelograms are used to represent input and output operations.
Statements like INPUT, READ and PRINT are represented in these Parallelograms.
c. Process Indicators: - Rectangle is used to indicate any set of processing operation such as for
storing arithmetic operations.
d. Decision Makers: The diamond is used for indicating the step of decision making and
therefore known as decision box. Decision boxes are used to test the conditions or ask questions
and depending upon the answers, the appropriate actions are taken by the computer. The
decision box symbol is
e. Flow Lines: Flow lines indicate the direction being followed in the flowchart. In a Flowchart,
every line must have an arrow on it to indicate the direction. The arrows may be in any direction
f. On- Page connectors: Circles are used to join the different parts of a flowchart and these
circles are called on-page connectors. The uses of these connectors give a neat shape to the
flowcharts. Ina complicated problems, a flowchart may run in to several pages. The parts of
the flowchart on different pages are to be joined with each other. The parts to be joined are
indicated by the circle.
2. Draw a flowchart for adding the integers from 1 to 100 and to print the sum.
PSEUDO CODE
The Pseudo code is neither an algorithm nor a program. It is an abstract form of a program. It
consists of English like statements which perform the specific operations. It is defined for an
algorithm. It does not use any graphical representation. In pseudo code, the program is
represented in terms of words and phrases, but the syntax of program is not strictly followed.
Advantages: * Easy to read, * Easy to understand, * Easy to modify.
Example: Write a pseudo code to perform the basic arithmetic operations.
Read n1, n2
Sum = n1 + n2
Diff = n1 – n2
Mult = n1 * n2
Quot = n1/n2
Print sum, diff, mult, quot
End.
OFFICE APPLICATION SOFTWARE
MICROSOFT EXCEL
INTRODUCTION
Microsoft Excel is a spreadsheet program designed by Microsoft Corporation for spreadsheet
analysis. The spreadsheet is made of columns and rows similar to accounting worksheets. This
program is generally used by all managers, accountants, bankers, cashiers etc. This enable them
to adequately process and manage their daily generated data.
Some of the functions of spreadsheet packages include:
Ability to perform calculation, with automatic summation facility.
Ability to update formula cells
Various formatting facilities to format workbook
Input data validation strategies
Chart creations
Auditing worksheets etc.
Features of MS Excel
Workbook- A workbook is the file equivalent of the spreadsheet package on which
work is performed and data are stored. The workbook is made up of several worksheets,
which allows various kinds of related information to be organized in a single workbook.
Active sheet-The active sheet is the worksheet where you are currently working on in
a workbook. The sheet tab of the active sheet is highlighted on the worksheet bar.
Cell- A cell is the intersection of a row and column. A cell is addressed by using its cell
address e.g. B1, C5, H2 etc.
Cell address or Reference- The columns in a worksheet are labelled with alphabetic
characters A, B, C, ……, while the rows are labelled with numeric values 1, 2, 3, 4…..
A cell is addressed or referenced by using the column letter with its corresponding row
value e.g. B1, C5, K4, etc.
Range- A range is a rectangular block of cells. A range can consist of a single cell,
some selected cells, an entire worksheets or all the worksheets in a workbook.
Range address- A range is identified by its address. A range address or reference
consists of the top left and bottom right cells in the range, separated by two periods or
colon e.g. A1..H20, B2:K4, C5:D8 etc.
Chart- Charts are used to graphically present data. Reports presented with the aid of
charts are always brief and comparison can easily be made among grouped data. Charts
are of different types (Bar, Pie, Area, Line, etc.) and the choice of any of the chart is
greatly influenced by the type of report to present.
Chart sheet- This is a sheet in a workbook that contains only a chart. This sheet is
labelled with Chart1, Chart2, Chart3 etc. to distinguish it from worksheets. Chart sheets
are linked to their respective worksheet data and they are updated automatically
whenever changes are made to the source data.
Formula- Formula is written to perform arithmetic operations such as addition (+),
subtraction (-), multiplication (*), and division (/). The formula is written once and
copied to other cells in return. A formula is preceded by a formula indicator, a symbol
such as “=” e.g. = SUM (E4:F8), =(D4*4)-E2 etc.
Formula Bar- The formula bar appears at the top of a spreadsheet window, it can be
used to enter or edit values or formulas in cells. In general, content of the active cell is
displayed on the formula bar.
Operators- Operators are used in a formula to indicate action to be performed on the
arguments (operands). Basic operators in excel include addition (+), subtraction (-),
multiplication (*), division (/) and exponentiation (^).
Functions- Functions are pre-written (in-built) formulas use to perform some standard
computations. Examples of functions are sum, product, average, maximum, minimum,
sin, standard deviation etc. For example, = SUM(C3:D8) will return the result of
addition of the contents of cell C3 to D8, =SIN(30) return the sin of an angle 30.
HANDS-ON
The students should be introduced to practical in MS Excel such as Formulas, SUM,
Percentage, IF, Nested IF, AND, OR functions etc.
Creating a Document
When a new document is created it has to be formatted to look attractive and presentable. This
determines how the document will look like when finished and printed. The author of the
document could decide to format the document before or after typing.
Steps to Create a blank document
1. Open Word. Or, if Word is already open, select File > New.
2. Select Blank document.
Exercise 1: Type the following passage
New rules to Rationale management;
Foremost: Rationale is the justification of decisions. Rationale models represents the
reasoning that leads to the decisions, including its functionality- and its implementation.
Rationale is critical in two areas: It supports the decisions making and it supports the capture
of knowledge. Rationale includes:
The issues that were addressed
The alternatives that were considered
The decisions that were made to resolve the issues
The criteria that were used to guide decisions
In the context of decision making the rationale improves the quality of decisions by making
decision elements, such as criteria, priorities, and arguments, explicit. In the context of
knowledge capture, the rationale is the most important information in the development process.
Saving a Document
It is good to cultivate the habit of saving one’s work periodically while typing to avoid loss of
information in case of an interrupted power supply.
Word Art
Use text art to change words in your documents into designs. Word Art designs are graphic
images. They are contained in a graphics box in MS word.
How to Insert WordArt
Word Art is designed to allow you make your text more attractive; you can format your text to
make it look like a picture and enhance its appearance in different ways. The steps to insert
WordArt are given below;
o Place the cursor where you want to insert WordArt
o Select the Insert tab
o In Text group click the 'WordArt' button
o WordArt menu appears;
A
drop cap (dropped capital) is a large capital letter used as a decorative element at the
beginning of a paragraph or section. The size of a drop cap is usually two or more
lines.
Add a drop cap
1. Select the first character of a paragraph.
2. Go to INSERT > Drop Cap.
3. Select the drop cap option you want.
To create a drop cap that fits within your paragraph, select Dropped.
To create a drop cap that is in the margin, outside of your paragraph, select In
margin.
MAIL MERGE
Mail merge is an MS word feature that lets you create letters for a number of people without
typing the original letter more than once. The letter is saved in a separate file called form file.
A letter form file contains all the formatting information, text, and graphics you want to be
common to each other. Next you create the data file that contains all the names and addresses
that should go with the letter. Finally, in order to create the complete letters, you merge the
form file with the data file.
Steps to create Mail Merge
1. In a blank Microsoft Word document, click on the Mailings tab, and in the Start Mail
Merge group, click Start Mail Merge.
2. Click Step-by-Step Mail Merge Wizard
3. Select your document type. In this demo we will select Letters. Click Next: Starting
document.
4. Select the starting document. In this demo we will use the current (blank) document.
Select Use the current document and then click Next: Select recipients.
5. Select recipients. In this demo we will create a new list, so select Type a new list and
then click Create.
Create a list by adding data in the New Address List dialog box and clicking
OK.
Save the list.
Note that now that a list has been created, the Mail Merge Wizard reverts to Use
an existing list and you have the option to edit the recipient list.
Selecting Edit recipient list opens up the Mail Merge Recipients dialog box,
where you can edit the list and select or unselect records. Click OK to accept
the list as is.
Click Next: Write your letter.
6. Write the letter and add custom fields.
Click Address block to add the recipients' addresses at the top of the document.
In the Insert Address Block dialog box, check or uncheck boxes and select
options on the left until the address appears the way you want it to.
Note that you can use Match Fields to correct any problems. Clicking Match
Fields opens up the Match Fields dialog box, in which you can associate the
fields from your list with the fields required by the wizard.
7. Press Enter on your keyboard and click Greeting line to enter a greeting.
8. In the Insert Greeting Line dialog box, choose the greeting line format by clicking the
drop-down arrows and selecting the options of your choice, and then click OK.
9. Note that the address block and greeting line are surrounded by chevrons (« »). Write a
short letter and click Next: Preview your letters.
LABORATORY EXERCISE
1. The tutor should guide the students in the computer Laboratory on how to generate and
insert automatic table of contents in MS word.
INTRODUCTION TO FORTRAN
FORTRAN is the programming language that gave birth to many scientific computer languages
available today. The name FORTRAN means FORmula TRANslation. The language was
developed by a team led by John Backus in 1954. The language is one of the earliest high level
languages. The language was released officially in April 1957 and by 1958, more than 50% of
all IBM 704 computer programs were written in FORTRAN. There are a lot of problems with
the initial FORTRAN such as no subroutines, limited number of statement types. These
problems were addressed in FORTRAN II and it was released towards the end of 1958.
In 1962 FORTRAN IV was released which is a major improvement to FORTRAN II.
FORTRAN IV was used for almost 15 years before the release of FORTRAN 77 IN 1977. The
next major update after FORTRAN 77 was FORTRAN 90 which was followed by FORTRAN
95, FORTRAN 2003 and FORTRAN 2008, respectively.
For this course, FORTRAN 95 and FORTRAN 2003 will be the focus in CMP 101 and two
language variants will be referred to as FORTRAN 95/2003.
INSTALL FTN95 PERSONAL EDITION
Search for Silverfrost FTN5 personal edition or click this link
http://www.silverfrost.com/32/ftn95/ftn95_personal_edition.aspx.
Download and install the software accepting all the defaults.
When you compile and execute the above program it produces the following result:
2147483647
Note that the huge() function gives the largest number that can be held by the specific integer
data type. You can also specify the number of bytes using the kind specifier. The following
example demonstrates this:
program testingInt
implicit none
!two byte integer
integer(kind=2) :: shortval
!four byte integer
integer(kind=4) :: longval
!eight byte integer
integer(kind=8) :: verylongval
!sixteen byte integer
integer(kind=16) :: veryverylongval
!default integer
integer :: defval
print *, huge(shortval)
print *, huge(longval)
print *, huge(verylongval)
print *, huge(veryverylongval)
print *, huge(defval)
end program testingInt
When you compile and execute the above program, it produces the following result:
32767
2147483647
9223372036854775807
170141183460469231731687303715884105727
2147483647
Real Type
It stores the floating point numbers, such as 2.0, 3.1415, -100.876, etc.
The following example shows the use of real data type:
program division
implicit none
! Define real variables
real :: p, q, realRes
! Define integer variables
integer :: i, j, intRes
! Assigning values
p = 2.0
q = 3.0
i=2
j=3
! floating point division
realRes = p/q
intRes = i/j
print *, realRes
print *, intRes
end program division
When you compile and execute the above program it produces the following result:
0.666666687
Complex Type
This is used for storing complex numbers. A complex number has two parts, the real part and
the imaginary part. Two consecutive numeric storage units store these two parts.
For example, the complex number (3.0, -5.0) is equal to 3.0 – 5.0i
Logical Type
There are only two logical values: .true. and .false.
Character Type
The character type stores characters and strings. The length of the string can be specified by
len specifier. If no length is specified, it is 1.
For example,
character (len=40) :: name
name = “Zara Ali”
The expression, name(1:4) would give the substring “Zara”.
Implicit Typing
Older versions of FORTRAN allowed a feature called implicit typing, i.e., you do not have to
declare the variables before use. If a variable is not declared, then the first letter of its name
will determine its type.
Variable names starting with i, j, k, l, m, or n, are considered to be for integer variable and
others are real variables. However, you must declare all the variables as it is good programming
practice. For that you start your program with the statement:
implicit none
This statement turns off implicit typing.
FORTRAN ─ VARIABLES
A variable is nothing but a name given to a storage area that our programs can manipulate.
Each variable should have a specific type, which determines the size and layout of the variable's
memory; the range of values that can be stored within that memory; and the set of operations
that can be applied to the variable.
The name of a variable can be composed of letters, digits, and the underscore character.
A name in FORTRAN must follow the following rules:
It cannot be longer than 31 characters.
It must be composed of alphanumeric characters (all the letters of the alphabet, and the
digits 0 to 9) and underscores (_).
First character of a name must be a letter.
Names are case-insensitive.
Variable Declaration
Variables are declared at the beginning of a program (or subprogram) in a type declaration
statement.
Syntax for variable declaration is as follows:
type-specifier :: variable_name
The following example demonstrates variable declaration, assignment and display on screen:
program variableTesting
implicit none
! declaring variables
integer :: total
real :: average
complex :: cx
logical :: done
character(len=80) :: message ! a string of 80 characters
!assigning values
total = 20000
average = 1666.67
done = .true.
message = "A big Hello from Tutorials Point"
cx = (3.0, 5.0) ! cx = 3.0 + 5.0i
Print *, total
Print *, average
Print *, cx
Print *, done
Print *, message
end program variableTesting
When the above code is compiled and executed, it produces the following result:
20000
1666.67004
(3.00000000, 5.00000000 )
T
A big Hello from Tutorials Point
FORTRAN ─ CONSTANTS
The constants refer to the fixed values that the program cannot alter during its execution. These
fixed values are also called literals.
Constants can be of any of the basic data types like an integer constant, a floating constant, a
character constant, a complex constant, or a string literal. There are only two logical constants
: .true. and .false.
The constants are treated just like regular variables, except that their values cannot be modified
after their definition.
There are two types of constants:
Literal constants
Named constants
A literal constant have a value, but no name.
A named constant has a value as well as a name.
Named constants should be declared at the beginning of a program or procedure, just like a
variable type declaration, indicating its name and type. Named constants are declared with the
parameter attribute. For example,
real, parameter :: pi = 3.1415927
Example
The following program calculates the displacement due to vertical motion under gravity.
program gravitationalDisp
! this program calculates vertical motion under gravity
implicit none
! gravitational acceleration
real, parameter :: g = 9.81
! variable declaration
real :: s ! displacement
real :: t ! time
real :: u ! initial speed
! assigning values
t = 5.0
u = 50
! displacement
s = u * t - g * (t**2) / 2
! output
print *, "Time = ", t
print *, 'Displacement = ',s
end program gravitationalDisp
When the above code is compiled and executed, it produces the following result:
Time = 5.00000000
Displacement = 127.374992
FORTRAN ─ OPERATORS
An operator is a symbol that tells the compiler to perform specific mathematical or logical
manipulations. FORTRAN provides the following types of operators:
Arithmetic Operators
Relational Operators
Logical Operators
Let us look at all these types of operators one by one.
Arithmetic Operators
Following table shows all the arithmetic operators supported by FORTRAN. Assume variable
A holds 5 and variable B holds 3 then:
Example
Try the following example to understand all the arithmetic operators available in Fortran:
program arithmeticOp
! this program performs arithmetic calculation
implicit none
! variable declaration
integer :: a, b, c
! assigning values
a=5
b=3
! Exponentiation
c = a ** b
! output
print *, "c = ", c
! Multiplication
c=a*b
! output
print *, "c = ", c
! Division
c=a/b
! output
print *, "c = ", c
! Addition
c=a+b
! output
print *, "c = ", c
! Subtraction
c=a-b
! output
print *, "c = ", c
end program arithmeticOp
When you compile and execute the above program, it produces the following result:
c = 125
c = 15
c=1
c=8
c=2
Relational Operators
Following table shows all the relational operators supported by FORTRAN. Assume variable
A holds 10 and variable B holds 20, then:
Example
Try the following example to understand all the logical operators available in Fortran:
program logicalOp
! this program checks logical operators
implicit none
! variable declaration
logical :: a, b
! assigning values
a = .true.
b = .false.
if (a .and. b) then
print *, "Line 1 - Condition is true"
else
print *, "Line 1 - Condition is false"
end if
if (a .or. b) then
print *, "Line 2 - Condition is true"
else
print *, "Line 2 - Condition is false"
end if
! changing values
a = .false.
b = .true.
if (.not.(a .and. b)) then
print *, "Line 3 - Condition is true"
else
print *, "Line 3 - Condition is false"
end if
if (b .neqv. a) then
print *, "Line 4 - Condition is true"
else
print *, "Line 4 - Condition is false"
end if
if (b .eqv. a) then
print *, "Line 5 - Condition is true"
else
print *, "Line 5 - Condition is false"
end if
end program logicalOp
When you compile and execute the above program it produces the following result:
Line 1 - Condition is false
Line 2 - Condition is true
Line 3 - Condition is true
Line 4 - Condition is true
Line 5 - Condition is false
Logical Operators
Logical operators in FORTRAN work only on logical values .true. and .false.
The following table shows all the logical operators supported by FORTRAN. Assume variable
A holds .true. and variable B holds .false. , then:
When you compile and execute the above program it produces the following result:
Line 1 - Condition is false
Line 2 - Condition is true
Line 3 - Condition is true
Line 4 - Condition is true
Line 5 - Condition is false