Agenda Computer Languages Machine Language High-Level Programming Language Features of C Programming Language How to Write a Simple C Program

Download Agenda  Computer Languages Machine Language High-Level Programming Language Features of C Programming Language  How to Write a Simple C Program

Post on 21-Jan-2016




0 download


  • AgendaComputer LanguagesMachine LanguageHigh-Level Programming LanguageFeatures of C Programming LanguageHow to Write a Simple C ProgramHow to Record a C Program (typescript)

  • Computer ProgramsA program is a set of instructions to tell the computer what to do.In order to better understand the programming process, we will first see how computer programs have developed over the past 50 years.

  • ComputersComputers are electronic devices that transfer and store data in wires (or gates).Because the computer is an electronic device, the data within these wires or gates are either ON or OFF (like a light switch).A collection of these ON and OFF combinations are used to represent data in the form of binary code (eg 010100001010111 )

  • Evolution of ProgramsEarly programmers needed to write programs using binary code or machine language to tell the computer to perform various tasksAlthough the computer finds machine code efficient to perform tasks, early programmers found writing programs in machine code tedious and time-consuming.

  • Evolution of ProgramsGrace Hopper, while working for the U.S. Navy in the 50s developed a program to convert programs written in symbols to machine language - this was more convenient than writing a program using machine language.This program used symbols to represent operations. Unfortunately, these programs didnt work on all computers

  • Evolution of ProgramsHigh-level languages were developed to allow the program to be run on many different computer systems. These high-level languages are considered portable programming languages since they can run on many different computers. The programs are written in a form easily understood by the programmers (source code) and then a compiler program converts the source code into machine code to be run by the computer.Examples of high-level languages: FORTRAN, COBOL & C

  • C Programming LanguageThe C programming language was developed by Dennis Ritchie at Bell AT&T labs in the early 1970s.Dennis Ritchie and Ken Thompson used the C programming language to rewrite the UNIX operating system in 1973.This contributed to the portability and popularity of C as UNIX operating system became widely accepted.

  • Features of C Programming LanguageC is portable (can write and compile C programs on many different computer systems without major adjustments)C is powerful, but also efficient.C conforms to the ASNI standard for programming languagesC provides the basis for more complex programming languages such as C++

  • Steps to Create a ProgramStep 1: Determine the requirements for the program (inputs, outputs, formulas)Step 2: Plan out on paper the logic of the program (flowchart, pseudo code)Step 3: Use Text editor to enter program (Source Code)Step 4: Walk through programs logic and syntax (look for errors)Step 5: Compile the source code into an executable fileStep 6: Run the executable file & test the programs logic as much as possible.

  • Debugging a ProgramDebugging a program is the process of finding and removing errors from your program if it fails to compile or run properlyThe compiler will NOT create an executable file if the source code contains syntax errors (but compiler will give error messages to help solve problem)If you can compile your source code, errors can still occur due to improper logic, structure, or design approach.

  • Writing a Simple C Program

    #include main () { printf (Hello World!\n); }Indicates to include a file that provides standard input / output functions (printf, scanf) which will be linked when source file is compiled

  • Writing a Simple C Program

    #include main () { printf (Hello World!\n); }Indicates main function or main part of the program. All C programs have one main function. Note all lowercase. Syntax may also allow: main (void) int main (void)

  • Writing a Simple C Program

    #include main () { printf (Hello World!\n); }Notice braces follow the main function. Other functions or commands are placed within these brackets to be executed when main function is run or called beginend

  • Writing a Simple C Program

    #include main () { printf (Hello World!\n); }Notice how commands within braces are indented to stand-out. This allows programmers to be able to easily read code. Indenting is very important!

  • Writing a Simple C Program

    #include main () { printf (Hello World!\n); }The printf command allows the display of output to be formatted: Some special codes include: \n - new line \t - tab (indent) \a - beep (alarm)Note: lowercase

  • Writing a Simple C Program

    #include main () { printf (Hello World!\n); }Most C commands end with a semi-colon.

  • Writing a Simple C ProgramTask:Write a C program to display the following information on a separate line:Your name Your student number Your section Tell us about yourself

  • TypescriptThe script command in the Unix operating system is like a tape recorder:Entering command script starts recordingall output on screen is saved to a file called typescriptEntering command exit stops recording

    Refer to Assignment #0 for practice of printing out - Assignment is not for marks.


View more >