UNB/ CS/ David Bremner/ tags/ 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

Posted Tags: /tags/C
  • 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

Posted Tags: /tags/C
  • Chapter 17 Dynamic memory allocation, linked lists

  • slides printable

  • about slides

Posted Tags: /tags/C

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 Tags: /tags/C
  • Chapter 17 Dynamic memory allocation

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Chapter 16,17 Enumerations, Pointers

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Chapter 16 Structures, Unions

  • slides printable

  • about slides

Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
  • Chapter 12. Pointers and Arrays, Chapter 13 Strings

  • slides printable

  • about slides

Posted Tags: /tags/C

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 Tags: /tags/C
  • Chapter 12. Pointers and Arrays

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Chapter 11, Chapter 12. pointers

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Chapter 10, Organization, Chapter 11

  • slides printable

  • about slides

Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
Posted Tags: /tags/C
  • Chapter 7, int, float, char, getchar, putchar

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Chapter 7, int, float, char, getchar, putchar

  • slides printable

  • about slides

Posted Tags: /tags/C
  • loops, goto-like statements, comma operator. Chapter 6 in King

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Logical Expresssions, if, conditional expressions

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Expresssions. Chapter 4,5 of King.

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Expresssions. Chapter 4 of King.

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Formatted I/O, Expresssions. Chapter 3,4 of King.

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Formatted I/O, Chapter 3 of King.

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Introduction to C, Chapter 2, 3 of King.

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Introduction to C, Chapter 2 of King.

  • slides printable

  • about slides

Posted Tags: /tags/C
  • Introduction to C, chapters 1 and 2 of King.

  • slides printable

  • about slides

Posted Tags: /tags/C