Docsity

Programming in C - Slideshow 2, Cheat Sheet of Computer science

Partial preview of the text

Download Programming in C - Slideshow 2 and more Cheat Sheet Computer science in PDF only on Docsity!

Programming in C

Introduction to C

C language  Facilitates a structured and disciplined approach to computer program design  Provides low-level access,  Highly portable

Basics of a Typical C Environment

Phases of C Programs:

  1. Edit
  2. Pre-process
  3. Compile
  4. Link
  5. Load
  6. Execute

Structure of a C program

The Basic Block

Return

Comments

  • Make programs easy to read and modify
  • Ignored by the C compiler
  • Two methods:
  1. // - line comment
    • Everything on the line following // is ignored //Purpose: Hello world
  2. /* */ - block comment
    • Everything between /* / is ignored / Program: First Date: mm/dd/yy */

Preprocessor Directive: #include

  • A C program line beginning with # that is processed by the compiler before translation begins.
  • #include pulls another file into the source o #include causes the contents of the named file, stdio.h, to be inserted where the # appears. File is commonly called a header file.  <>’s indicate that it is a compiler standard header file. //Purpose: Hello world o #include “myfunctions.h” causes the contents of myfunctions.h to be inserted  “ ’s indicate that it is a user file from current or specified directory

Console Output - printf

 Print to standard output, typically the screen

 General format (value-list may not be required): printf(“format

string”, value-list); printf(“Hello World!\n”);

Console Output

Terminal Output

Escape Character