• Like
MSL2009. C language
Upcoming SlideShare
Loading in...5
×

MSL2009. C language

  • 482 views
Uploaded on

Presentation about C language done at Master on Free Software 2009 Edition

Presentation about C language done at Master on Free Software 2009 Edition

More in: Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
482
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
6
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. C language Juan A. Suárez Romero Master on Free Software
  • 2. List of topics ● History ● Control structures ● Data types ● Operators ● Preprocessor Master on Free Software
  • 3. History ● Developed by Dennis Ritchie ● Goal: port a SO from PDP-7 to PDP-8 ● K&R C ● Ansi C (C89/C90 - C99) Master on Free Software
  • 4. Example #include <stdio.h> int main(int argc, char *argv[]) { printf (“Hello, world!n”); return 0; } Master on Free Software
  • 5. Control structures while (condition) statement_set; do statement_set while (condition) for (initial_cond, final_cond, change_action) statement_set if (condition) st_set else st_set2; Master on Free Software
  • 6. Data Types ● Simple types – char, int, float, double – signed/unsigned ● Complex types – arrays, structures, unions – strings (arrays of char ended in NULL) ● 'Special' types – Pointers – Void Master on Free Software
  • 7. Data types #include <stdio.h> int main(int argc, char *argv[]) { char letter; double pi; float height; int first_prime_numbers[30]; } Master on Free Software
  • 8. Data types struct email { int sent_date; char *sender; char *subject; char *content; }; struct email *myemail; Master on Free Software
  • 9. Arrays / pointers ● Array is actually a pointer to a chunk of memory ● Uses of * and &    char *a;    char b;    *a?? &b?? (a = &b)?? (b = *a)?? ● Pointer arithmetic: a[3] == *(a+3) Master on Free Software
  • 10. Operators ● Arithmetic (+, -, *, /, %) ● Logical (&&, ||, ==, !=, >=, <=) ● Increment / Decrement ● Size of a type ● Self assignment (+=, -=, ...) Master on Free Software
  • 11. Preprocessor ● Definitions – #define, #undef ● Conditional compiling – #if, #ifdef, #ifndef, #else, #endif ● Include other files – #include Master on Free Software
  • 12. Functions int multiply (int n1, int n2); int multiply (int n1, int n2) {        return n1*n2; } Master on Free Software
  • 13. References ● The C Programming Language (2nd edition) – Brian W. Kernighan – Dennis M. Ritchie Master on Free Software