17
CSCI 171 Presentation 1

CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Embed Size (px)

Citation preview

Page 1: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

CSCI 171

Presentation 1

Page 2: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Computer Software

• System Software– Operating systems– Utility programs– Language compilers

• Application Software

Page 3: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Language Compilers

• Programming Generations– 5 Generations

• 1GL - Machine Language• 2GL - Assembly Language• 3GL - Compiled Languages

– Procedural» COBOL» C

– OOP» Java» C++

• 4GL – SQL• 5GL

Page 4: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

History of C

• Bell Telephone Laboratories (1972)

• Dennis Ritchie (also created UNIX)

• A - B - C

Page 5: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Initially Many Versions

• Incompatibility

• ANSI– American National Standards Institute

• ANSI Standard C

Page 6: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Advantages of C

• Powerful, Flexible– Operating Systems– Applications software– Compilers

• Popular

• Portable

• Modular (should be written in functions)

Page 7: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Problem Solving Technique

• Define Problem

• Devise plan to fix problem

• Implement the plan

• Test

Page 8: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Necessary Information

• Is computer program required?

• Inputs/Outputs

• Formulas

• Organization (flow of logic)

Page 9: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Ex: Find area of a circle

• Is computer required?

• Inputs / Outputs– Need the radius of circle as input– Area will be the output

• Formulas– Area = pi * radius ^ 2

Page 10: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Find area of circle - continued

• Flow of logic:– Request radius of circle– Calculate area = pi * radius ^ 2– Output area

Page 11: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Steps in C programming cycle

• Use editor to create source code

• Compile source code into object code

• Link object file into executable file

• Execute file

Page 12: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Use editor to create source code

• Any editor can be used– Editor supplied with language

• Any text based editor

• DOS editor

• Notepad

• Write program following syntax of language

• Save file as: filename.c

Page 13: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Compile Source Code

• Different compilers use different commands

• Most (such as Borland, Code Warrior) have IDE - can compile via GUI interface

• Process creates a new file: filename.obj

• This file is object code - in format readable by machine

Page 14: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Link object file

• Most compilers will do this via GUI interface as well (may combine compiling and linking)

• Links internal C library functions (such as printf, scanf) with source code

• Creates new file: filename.exe

Page 15: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Execute Program

• Program can now be executed– Type filename at DOS prompt– Most compilers allow program to be run via

GUI interface• may combine compiling, linking, and running

• Finished product can be shared– source code does not have to be shared

Page 16: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Using the CodeWarrior compiler• Open up CodeWarrior through the Start Menu

– Metrowerks CodeWarrior…CodeWarrior IDE

• Select New…  from the File menu• Select 'Win32 C Stationary‘• Enter (or select) the location• Enter the project name• Click 'Ok‘• Click on the + next to 'Win32 Console App‘• Double click 'C Console App‘• Open up the 'Source' folder by clicking on the + next to it• Double click main.c - this will open up a text based editor where you can type your

program (there will be some code in there automatically, you can delete it or change it)

• Write the source code• Run the program by selecting Run from the Project menu.

Page 17: CSCI 171 Presentation 1. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software

Sample C Program – Circle Area#include <stdio.h>

int main( void ) {const double pi = 3.14159;double radius = 0.0, area = 0.0;

printf("Enter the radius of the circle: ");scanf("%lf", &radius);

area = radius*radius*pi;

printf("The area of the circle is: %lf", area);}