1 / 36

Chapter Two Introduction to the Programming Language C

Chapter Two Introduction to the Programming Language C. The only way to learn a programming language is by writing programs in that language. The Programming Language C. C is a general-purpose programming language C is developed by Dennis Ritchie at Bell Laboratories

Download Presentation

Chapter Two Introduction to the Programming Language C

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. Chapter TwoIntroduction tothe Programming Language C

  2. The only way to learn a programming language is by writingprograms in that language

  3. The Programming Language C • C is a general-purpose programming language • C is developed by Dennis Ritchie at Bell Laboratories • C has become one of the most widely used languages in the world

  4. The C Programming System • C programming language • A set of notations for representing programs • C standard library • A set of well-developed programs • C programming environment • A set of tools to aid program development

  5. library programs in machine language user-written programs in machine language The C Programming System Editor user-written programs in C language environment Compiler library Debugger

  6. The First C Program Print the following words hello, world

  7. The First C Program #include<stdio.h> main( ) { printf(“hello, world\n”); }

  8. Programs • A C program consists of functions and variables • A function contains instructions that specify the operations to be done during the computation • Variables denote memory locations that store data used during the computation

  9. Functions • Functions can be either user-defined functions or library functions • A C program begins the execution at the beginning of the function named main • A function may call other functions to help it perform one of its subtasks

  10. The First C Program #include<stdio.h> /* include library information */ main( ) /* name of starting function */ { /* beginning of instructions */ printf(“hello, world\n”); /* call library function */ } /* end of instructions */

  11. Arguments • One method of communicating data between functions is for the calling function to provide a list of values, called arguments, to the called function • The parentheses after the function name surround the argument list

  12. Strings • A character string or string constant is a sequence of characters enclosed in double quotes • The backslash \ in a string is used as an escape character. It is used for representing invisible characters • Some common escape sequences\\ backslash \b backspace\n newline \t tab\" double quote \' single quote

  13. C Programming Environment prog1.c, prog1.h, prog2.c, prog2.h Edit prog1.obj, prog2.obj Compile lib.h prog.exe Link lib.obj output Debug input Execute

  14. C Programming Environment • Edit: create the high-level language program files using the editor • Compile: translate the high-level language program into the machine language program using the compiler • Link: combine user's machine language program and the library using the linker

  15. C Programming Environment • Execute: run the combined machine language program • Debug: correct the errors in the program • syntax errors • linking errors • runtime errors • logical errors

  16. Microsoft Visual C++

  17. Creating the Source File

  18. Creating the Source File

  19. Editing the Source File

  20. Saving the Source File

  21. Saving the Source File

  22. Saving the Source File

  23. Compiling the Source File

  24. Compiling the Source File

  25. Compiling the Source File

  26. Linking the Object Files

  27. Linking the Object Files

  28. Executing the Executable File

  29. Executing the Executable File

  30. Executing the Executable File

  31. Debugging Syntax Errors

  32. Debugging Linking Errors

  33. Debugging Runtime Errors

  34. Debugging Logical Errors

  35. Debugging Logical Errors • All programmers make logic errors (bugs). In particular, you will make logic errors • Good programmers is ones who take pains to minimize the number of bugs that persist in the finished code • Always be skeptical of your own programs and test them as thoroughly as you can

  36. Software Maintenance • Software requires maintenance • Bug repair • Feature enhancement • The cost of software maintenance constitutes between 80 and 90 percent of the total cost • Software engineering is the discipline of writing programs so that they can be understood and maintained by others • Good programming style requires developing an aesthetic sense

More Related