Professional Documents
Culture Documents
Algorithms
Coming Up ….
• Recent Roles
• History
• Bad forecasting
• How it works
– Hardware
– Software
• The language
• Algorithms
Computer – recent development
• Deep blue defeated Garry Kasparov
• Analysing & recognizing faces of
terorist suspects
• Weather forecasts
– Butterfly in China Storms in the U.S.
and so on …
Bad forecasting about computers
• "Computers in the future may weigh no
more than 1.5 tons."
--Popular Mechanics, forecasting the relentless march of
science, 1949
Memory(RAM)
Memory
System Unit
Digital Computer Hardware (2)
Control Unit
1
Fetch 2 Decode
Execution
CPU Cycle
RAM
3 Execute
4 Store
Arithmetic/Logic Unit
Includes Cache
(very fast memory)
Open architecture
on computer design
How it works – software
Programming Languages
Classified as
Low L evel
• Machine Language
(binary-based code; machine dependent)
• Assembly Language
(mnemonic form of machine language)
High Level
High Level
• Closer to natural languages.
• Generally, machine independent
• Usually, several machine instructions are
combined into one high-level instruction.
• Examples:
FORTRAN COBOL BASIC Java
Pascal Ada PL/I Lisp
C GPSS C++ Matlab
Processing a High-Level Language
Program
Programs written in high-level languages
must be converted to machine language.
Two approaches:
(1) Compilation (see p. 28 FER Figure 2.4)
Used with C, C++, Fortran,...
(2) Interpretation
Used with Matlab, Visual Basic,...
Compilation
Step 1) Use Xemacs to create a “source” file.
We will name source files with a suffix “.c”
Output::resistance
Circle used as
continuation symbol
for transfer to another
stop
page.
C Program Example
4. Implementat ion -- - W rite t he "P rogr am " (Code)
(see the next s lid e)
C Code Implementation of the Algorithm
/* C Program to compute the resistance */
/* of a light-bulb.*/
#include <stdio.h>
#define VAC 117.0
void main(void)
{
/* Declare variables. */
float power, resistance;
/* request user input power of */
/* light-bulb in watts. */
printf(”Please enter power(watts) :”);
/* read value power */
scanf("%f", &power);
/* Compute resistance assuming VAC = 117. */
resistance = (VAC * VAC) /power;
/* Output the calculated resistance. */
printf(”Resistance is %f (ohms)\n", resistance);
}
(Note indentation scheme in above code.)
Open Xemacs and enter
C pr ogram compi lati on
your code..
C program compilation
C pr ogram compi lati on
Click the “Save” button in Xemacs to save your code but
don’t close the Xemacs window.
Click the xterm button to open another window.
C pr ogram compi lati on
> ls
resistance.c resistance.c~