1. Write a structure for date w/ month, day and year.
    • struct date {
    • int month;
    • int day;
    • int year;
    • };
  2. Change the structure 'struct date' to be just date.
    typedef struct date date;
  3. Declare a new variable of a structure date. Name it finsky
    date finsky;
  4. What is wrong with: struct date { int month; int day; int year; }
    Forgot Semicolon at end of declaration.
  5. How to you find the address of a variable?
  6. Where do you define global structures in the program?
    Outside of any function and first. (after #include)
  7. What do you need to include to access type bool?
  8. Can you pass structures as arguments?
    Yes. You can return structures too.
  9. Is this correct? struct date today = {7,5,2006};
  10. Is this correct? struct date today = {day = 7};
    No. Need a . infront of day
  11. Is this correct? today = (struct date) {9,25,1985};
  12. What is an example of initializing a structure using a compound literal?
    declaredVar = (StuctType) {1,50,1095};
  13. How do you create the listNode structure?
    • struct listNode {
    • int value;
    • listNode *next;
    • };
  14. How do you initialize a list?
    • void initializeList() {
    • head = NULL;
    • numItems = 0;
    • }
  15. What is a pointer?
    A var that contains a memory address.
  16. What are pointers used for?
    To access memory and manipulate addresses.
  17. What is * operator used for?
    Access pointed-To
  18. Does * let you access the value stored in the pointer?
    No! It lets you access the value stored in pointed to!
  19. What is the unary address operator?
  20. How do you assign a pointer?
    *p = &var
  21. How do you print a pointer value?
  22. Can you declare a void pointer?
    Yes, void *p;
  23. What is the structure Pointer Operator?
    -> equivalent to (*pointer_to_structure).memberName
  24. Which has preference -> or . ?
    They are equal
  25. What type is a pointer to a structure?
    The same type as the structure
  26. What is this? p->next
    a structure with a pointer to it, referencing a member called next
  27. What does getchar() do?
    It reads a character from the keyboard.
  28. How do you concatenate strings?
  29. How do you copy one string into another?
    strcpy(designation, copied)
  30. How do you count the number of characters in a string before \0?
  31. What header file must be included to use calloc() and malloc()?
  32. What is the difference between calloc and malloc?
    calloc initializes to zero.
  33. what two arguments does calloc require?
    number of objects, size of object
  34. What do you need to remember to do with dynamically allocated memory?
    Free it when your done! free(var);
  35. What does calloc return?
    A void pointer to a space in dynamic memory.
  36. How do you print a tab character?
  37. How does Binary Search work?
    Split in half, search half.
  38. How many comparisons does Binary search require?
  39. When a programmer says log which base are they referring to?
  40. How does Bubble sort work?
    Compare adjacent, swap if necessary
  41. Hoe does selection sort work?
    Find largest item, and move to end.
  42. How does insertion sort work?
    Sorted region and unsorted. At each step move first unsorted into proper position
Card Set
C programming