1 / 7

DASL 130 – C Programming Course

DASL 130 – C Programming Course. Lecture 3. Switch Statement. switch(case){ label: code break; label2: code break; default: code }. Function Basics. return type name (argument list) return type void (for none) or int, char, double, etc name

lamar
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 3

  2. Switch Statement switch(case){ label: code break; label2: code break; default: code }

  3. Function Basics • return type name (argument list) • return type • void (for none) or int, char, double, etc • name • starts with a letter, no special characters or keyword like a variable • argument list • int input, double input2, char input3 etc

  4. Function Prototype • Same as function declaration, just no contents • Goes before main int functionName(int input); void main(int input2){ int var = functionName(4.0); } int functionName(int input){ return input*2; }

  5. Pass by Value / Reference • By Value – normal method, does not alter variable contents • By Reference – passes memory location int function(int *refvar){ (*refvar) +=2; }

  6. Recursion • Functions that call themselves • Fibonacci sequence F(n) = F(n-1) + F(n-2) 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

  7. Math • #include <math.h> • sin(angle); • cos(angle); • log(natural); • log10(base10); • pow(base, exponent); • sqrt(input); • more…

More Related