UNB/ CS/ David Bremner/ tags/ cs2023/ C

This feed contains pages with tag "C".

  • Chapter 15, multiple compilation units, include files, makefile

  • slides printable

  • about slides

  • Chapter 15, multiple compilation units, include files

  • slides printable

  • about slides

  • Chapter 17 variable sized structs. Chapter 15, multiple compilation units, include files

  • slides printable

  • about slides

  • Chapter 17 Dynamic memory allocation, linked lists, variable sized structs

  • slides printable

  • about slides

  • Chapter 17 Dynamic memory allocation, linked lists

  • slides printable

  • about slides

Posted Wed 25 Nov 2009 12:00:00 AM AST Tags:

Fill in the three missing functions in this code, so that numbers are printed out in order. Note that you can debug print_numbers independently.

#include <stdio.h>
#include <stdlib.h>

struct node {
  int value;
  struct node *next;
};

struct node *read_numbers(void){
  struct node *first = NULL;
  int n;
  printf("Enter a series of integers" 
         " (0 to terminate): ");
  for (;;) {
    scanf("%d", &n);
    if (n == 0)
      return first;
    first = add_to_list(first, n);
  }
}

struct node *reverse(struct node *list){
}

struct node *add_to_list(struct node *list, n){
}

void print_numbers(struct node *list){
}

int main(void){
  struct node *list=NULL;

  list=read_numbers();
  list=reverse(list);
  printf("output: \n");
  print_numbers(list);
}
Posted Tue 24 Nov 2009 12:00:00 AM AST Tags:
  • Chapter 17 Dynamic memory allocation

  • slides printable

  • about slides

Posted Mon 23 Nov 2009 12:00:00 AM AST Tags:
  • Chapter 16,17 Enumerations, Pointers

  • slides printable

  • about slides

Posted Fri 20 Nov 2009 12:00:00 AM AST Tags:
  • Chapter 16 Structures, Unions

  • slides printable

  • about slides

Posted Wed 18 Nov 2009 12:00:00 AM AST Tags:
Posted Mon 16 Nov 2009 12:00:00 AM AST Tags:
Posted Fri 13 Nov 2009 12:00:00 AM AST Tags:
Posted Mon 09 Nov 2009 12:00:00 AM AST Tags:
Posted Wed 04 Nov 2009 12:00:00 AM AST Tags:
Posted Mon 02 Nov 2009 12:00:00 AM AST Tags:
Posted Fri 30 Oct 2009 12:00:00 AM ADT Tags:
  • Chapter 12. Pointers and Arrays, Chapter 13 Strings

  • slides printable

  • about slides

Posted Wed 28 Oct 2009 12:00:00 AM ADT Tags:

Exercises from Chapter 11,12 of King

  1. Given the following declarations
int i;
int *p,*q;        

Which of the following assignments are legal

p=i;
*p=&i;
&p=q;
p=&q;
p=*&q;
p=q;
p=*q;
*p=q;
*p=*q;
  1. Write the following function
void find_two_largest(int a[], int n, int *largest, int *second_largest);
  1. What will be the contents of array a after the following code is executed?
#define N 10
int a[N] = {1,2,3,4,5,6,7,8,9,10};
int *p=a,*q=a+N-1;
while(p<q){
  int temp=*p;
  *p++=*q;
  *q--=temp;
}
Posted Tue 27 Oct 2009 12:00:00 AM ADT Tags:
  • Chapter 12. Pointers and Arrays

  • slides printable

  • about slides

Posted Mon 26 Oct 2009 12:00:00 AM ADT Tags:
  • Chapter 11, Chapter 12. pointers

  • slides printable

  • about slides

Posted Fri 23 Oct 2009 12:00:00 AM ADT Tags:
  • Chapter 10, Organization, Chapter 11

  • slides printable

  • about slides

Posted Wed 21 Oct 2009 12:00:00 AM ADT Tags:
Posted Mon 19 Oct 2009 12:00:00 AM ADT Tags:
Posted Fri 16 Oct 2009 12:00:00 AM ADT Tags:
Posted Wed 14 Oct 2009 12:00:00 AM ADT Tags:
Posted Fri 09 Oct 2009 12:00:00 AM ADT Tags:
Posted Mon 05 Oct 2009 12:00:00 AM ADT Tags:
  • Chapter 7, int, float, char, getchar, putchar

  • slides printable

  • about slides

Posted Fri 02 Oct 2009 12:00:00 AM ADT Tags:
  • Chapter 7, int, float, char, getchar, putchar

  • slides printable

  • about slides

Posted Wed 30 Sep 2009 12:00:00 AM ADT Tags:
  • loops, goto-like statements, comma operator. Chapter 6 in King

  • slides printable

  • about slides

Posted Mon 28 Sep 2009 12:00:00 AM ADT Tags:
  • Logical Expresssions, if, conditional expressions

  • slides printable

  • about slides

Posted Fri 25 Sep 2009 12:00:00 AM ADT Tags:
  • Expresssions. Chapter 4,5 of King.

  • slides printable

  • about slides

Posted Wed 23 Sep 2009 12:00:00 AM ADT Tags:
  • Expresssions. Chapter 4 of King.

  • slides printable

  • about slides

Posted Mon 21 Sep 2009 12:00:00 AM ADT Tags:
  • Formatted I/O, Expresssions. Chapter 3,4 of King.

  • slides printable

  • about slides

Posted Fri 18 Sep 2009 12:00:00 AM ADT Tags:
  • Formatted I/O, Chapter 3 of King.

  • slides printable

  • about slides

Posted Wed 16 Sep 2009 12:00:00 AM ADT Tags:
  • Introduction to C, Chapter 2, 3 of King.

  • slides printable

  • about slides

Posted Mon 14 Sep 2009 12:00:00 AM ADT Tags:
  • Introduction to C, Chapter 2 of King.

  • slides printable

  • about slides

Posted Fri 11 Sep 2009 12:00:00 AM ADT Tags:
  • Introduction to C, chapters 1 and 2 of King.

  • slides printable

  • about slides

Posted Wed 09 Sep 2009 12:00:00 AM ADT Tags: