UNB/ CS/ David Bremner/ tags/ C

This feed contains pages with tag "C".

Posted Fri 04 Dec 2009 12:00:00 AM AST Tags: /tags/C
Posted Wed 02 Dec 2009 12:00:00 AM AST Tags: /tags/C
Posted Mon 30 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Fri 27 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Wed 25 Nov 2009 12:00:00 AM AST 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 Tue 24 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Mon 23 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Fri 20 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Wed 18 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Mon 16 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Fri 13 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Mon 09 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Wed 04 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Mon 02 Nov 2009 12:00:00 AM AST Tags: /tags/C
Posted Fri 30 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Wed 28 Oct 2009 12:00:00 AM ADT 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 Tue 27 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Mon 26 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Fri 23 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Wed 21 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Mon 19 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Fri 16 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Wed 14 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Fri 09 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Mon 05 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Fri 02 Oct 2009 12:00:00 AM ADT Tags: /tags/C
Posted Wed 30 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Mon 28 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Fri 25 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Wed 23 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Mon 21 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Fri 18 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Wed 16 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Mon 14 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Fri 11 Sep 2009 12:00:00 AM ADT Tags: /tags/C
Posted Wed 09 Sep 2009 12:00:00 AM ADT Tags: /tags/C