1 / 10

DASL 130 – C Programming Course

DASL 130 – C Programming Course. Lecture 1. Compiler. A compiler turns C code into machine code, in other words an executable file Dev-C++ http://www.bloodshed.net/devcpp.html. Basic Program. “Hello World” Code: #include <stdio.h> int main() { printf("Hello World!"); scanf(" ");

elom
Télécharger la présentation

DASL 130 – C Programming Course

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. DASL 130 – C Programming Course Lecture 1

  2. Compiler • A compiler turns C code into machine code, in other words an executable file • Dev-C++ • http://www.bloodshed.net/devcpp.html

  3. Basic Program • “Hello World” Code: #include <stdio.h> int main() { printf("Hello World!"); scanf(" "); return 0; }

  4. Variables • Format: • Type name = value; • Variable names: start with a letter, can not be a keyword • Convention is lowercase for variables, uppercase for constants

  5. Types • Char – 1 byte • Signed is -128 to 127 • Unsigned is 0 to 255 • ASCII Table converts char values to characters • Escape sequences: • \n – new line • \r – line return • \t – tab • \’ \” - quotes

  6. Types • Int • short int – at least 16 bits • int – no larger than long, no shorter than short • long int – at least 32 bits (-2 billion to 2 billion) • long long int – at least 64 bits • Escape sequences • Octal - \000 • Hex - \x00

  7. Types • Float and Double • Float – 6 digit precision • Double – 12 digit precision • Precision is number of digits sizeof() – returns size of a variable in bytes

  8. Qualifiers and Casting • Type Qualifiers • const – variable cannot be modified • volatile – prevents compiler from optimizing around variable • Type Casting • Allows conversion of variable types • float test = (float)5

  9. Operators • Arithmetic + , - , * , / , % (modulus) ++ , -- (prefix and postfix incrementation) += , -= , *= , /= , %= • Logical && , || , == , != • Bit Shifting << , >> , | , & , ^

  10. Standard I/O • Basic Output – printf() • printf(“An integer is %d\n”, int var); • d/i = int, f = floating point, e = exponential notation, c = single char, s = string, o = octal, x/X = hex, u = unsigned int • Basic Input – scanf()

More Related