All pastes #368982 Raw Edit

Unnamed

public text v1 · immutable
#368982 ·published 2007-02-23 14:21 UTC
rendered paste body
Question 1  1 points    Save    
  if b is declared as char b[10] which of these statements does not returns the content of the 10th array cell:
 
    *(b+9);  
   b[9];  
   *b + 9;  
   *(&b[0] + 9);  
 


   Question 2  1 points    Save    
  The address of the 100th cell of an array, a, declared as int a [100]; is given by:  
    &a[100];  
   a + 99;  
   *a[100]  
   (*a)[99]  
 


   Question 3  1 points    Save    
  if a is declared as int a [10], p as int * p, and count as int then which of these pieces of code does not print the integers from a:
 
    for (count=0; count<10; count++) printf("%d ",a[count]);  
   for (p=a,count=0; count < 10; count++) printf("%d ",*p++);  
   for (p=a,count=0; count < 10; printf("%d ",*p),count++,p++);  
   for (p=a,count=0; count < 10; count++,p++,printf("%d ",*p));  
 


   Question 4  1 points    Save    
  If p is declared as char ** p which of these statements returns a char:
 
    p;  
   *p;  
   **p;  
   ***p;  
 


   Question 5  1 points    Save    
  If head is of type typeCell * where typeCell is defined as:

typedef struct cell {
     int value;
     struc * cell next;
} typeCell;

then which of these statements is incorrect:
 
    head->next;  
   head.next;  
   (*head).next;  
   head[0].next;  
 


   Question 6  1 points    Save    
  Suppose that p and q are of type typeCell * where typeCell is defined as:

typedef struct cell {
     int value;
     struc * cell next;
} typeCell;

Moreover assume that p points to one of the typeCell structure of a link list, and that q points to a typeCell structure newly allocated.

Which of these pieces of code correctly inserts the structure newly allocated in the linked list:
 
    q->next = p; p = NULL;  
   q = p->next; p->next = q;  
   p->next = q; q->next = p->next;
 
   q->next = p->next; p->next = q;  
 


   Question 7  1 points    Save    
  If swap is defined as 

swap (char * p, char * q)
{
    char ch;
    ch = *p, *p = *q, *q = ch;
}

and if p and q are defined of type char* then the effect of the call swap (&p,&q)
 
    is to exchange the content of the 2 pointer variables.  
   is to exchange the content of the memory cells pointed to by p and q.  
   is to do nothing (state of program identical after return of call).  
   is irrelevant as this is clearly incorrect programming.  
 


   Question 8  1 points    Save    
  If swap is defined as 

swap (char ** p, char ** q)
{
    char * pch;
    pch = *p, *p = *q, *q = pch;
}

and if p and q are  defined of type char* then the effect of the call swap (&p,&q)
 
    is to exchange the content of the 2 pointer variables.  
   is to exchange the content of the memory cells pointed to by p and q.  
   is to do nothing (state of program identical after return of call).  
   is irrelevant as this is clearly incorrect programming.  
 


   Question 9  1 points    Save    
  If swap is defined as 

swap (char ** p, char ** q)
{
    char ch;
    ch = **p, **p = **q, **q = ch;
}

and if p and q are  defined of type char* then the effect of the call swap (&p,&q)
 
    is to exchange the content of the 2 pointer variables.  
   is to exchange the content of the memory cells pointed to by p and q.  
   is to do nothing (state of program identical after return of call).  
   is irrelevant as this is clearly incorrect programming.  
 


   Question 10  1 points    Save    
  If swap is defined as 

swap (char  p, char  q)
{
    char ch;
    ch = p, p = q, q = ch;
}

and if p and q are  defined of type char* then the effect of the call swap (*p,*q)
 
    is to exchange the content of the 2 pointer variables.  
   is to exchange the content of the memory cells pointed to by p and q.  
   is to do nothing (state of program identical after return of call).  
   is irrelevant as this is clearly incorrect programming.