Attachment '1.c'

Download

   1 #include <stdio.h>
   2 
   3 int N = 5;
   4 
   5 void setabs( int *px )
   6 {
   7     //printf("inside setabs: before: x = %d\n", *px );
   8     if (*px < 0)
   9       *px = -*px;
  10     //printf("inside setabs:  after: x = %d\n", *px );
  11 }
  12 
  13 int main()
  14 {
  15     int n;
  16     int i;
  17     /*
  18     n = -7;
  19     printf("before: n = %d\n", n);
  20     setabs(&n);
  21     printf(" after: n = %d\n", n);
  22     */
  23 
  24     for( i = 0; i < N; i ++ )
  25     {
  26         scanf("%d", &n );
  27         setabs( &n );
  28         printf("%d\n", n );
  29     }
  30 
  31     return 0;
  32 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.