1 / 14

Lecture++: Review 10/29/2012

Lecture++: Review 10/29/2012. About Midterm Exam. Hold on 11/05 Few programming exercises at the class Have only web access to the course slides Bring other documents is not allowed. Data Type. int unsigned int long long int float double long double char. Input and Output. Format

vera-hanson
Download Presentation

Lecture++: Review 10/29/2012

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. Lecture++: Review10/29/2012

  2. About Midterm Exam • Hold on 11/05 • Few programming exercises at the class • Have only web access to the course slides • Bring other documents is not allowed

  3. DataType • int • unsignedint • longlongint • float • double • longdouble • char

  4. Input and Output • Format • %d, %lld, %u, %llu, %f, %lf, %c, %s • scanf(format, &arg1, &arg2, …); • printf(format, arg1, arg2, …); • gets(string); • puts(string); • getchar(); • putchar(char);

  5. Control Flow • Condition • &&, ||, !, ==, !=, >, <, >=, <= • if, else if, else • switch, case, default • for(<exp1>;<condition>;<exp2>){<statement>} • while(<condition>){<statement>} • do{<statement>}while(<condition>) • break, continue

  6. Function • Functionname • Listofparameters • Statement • Returntype

  7. Recursion • A function is recursive if it calls itself.

  8. Array • <Type> array_name[<Size>]; • Collection of same type elements • Constant size • Zero-based • Multidimensional array • int multi_array[n][m];

  9. Pointer • Declaration • Addressing operator (&) • Dereferencing operator (*) • Pointers and arrays are closely related • a[0] is the same as *a • a[1] is the same as *(a + 1)

  10. VariableScope • Globalvariable • Localvariable

  11. Memory • Heap • Stack • malloc(size) • free(address)

  12. CommonBugs -Typo • scanf(“%d”,n); • chars[10];scanf(“%c”,s); • charc=“a”; • if(a=1) • if(0<a<10) • if(a==b&b==c) • for(i=1;1<=n;i++) • while(i<10);i++;

  13. CommonBugs-Memory • Indexrangeofarray[n]isfrom0ton-1 • Usepointerwithoutmalloc() • Forgetting‘\0’intheendofstring • Callingfree()forthesameaddresstwice • Queryahugesizeofmemory

  14. CommonBugs-Others • Misunderstanding the problem • Uninitialized variable • Exceeding the range of int • Zerodivision • Forgettingtoputabreakinaswitch • Comparingstringswith“==”

More Related