1 / 17

CSCI 171

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

chaman
Download Presentation

CSCI 171

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI 171 Presentation 1

  2. Computer Software • System Software • Operating systems • Utility programs • Language compilers • Application Software

  3. Language Compilers • Programming Generations • 5 Generations • 1GL - Machine Language • 2GL - Assembly Language • 3GL - Compiled Languages • Procedural • COBOL • C • OOP • Java • C++ • 4GL – SQL • 5GL

  4. History of C • Bell Telephone Laboratories (1972) • Dennis Ritchie (also created UNIX) • A - B - C

  5. Initially Many Versions • Incompatibility • ANSI • American National Standards Institute • ANSI Standard C

  6. Advantages of C • Powerful, Flexible • Operating Systems • Applications software • Compilers • Popular • Portable • Modular (should be written in functions)

  7. Problem Solving Technique • Define Problem • Devise plan to fix problem • Implement the plan • Test

  8. Necessary Information • Is computer program required? • Inputs/Outputs • Formulas • Organization (flow of logic)

  9. 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

  10. Find area of circle - continued • Flow of logic: • Request radius of circle • Calculate area = pi * radius ^ 2 • Output area

  11. 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

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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.

  17. 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); }

More Related