home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list5_1.c < prev    next >
C/C++ Source or Header  |  1993-10-16  |  481b  |  25 lines

  1.    /* Demonstrates a simple function */
  2.    #include <stdio.h>
  3.  
  4.    long cube(long x);
  5.  
  6.    long input, answer;
  7.  
  8.    main()
  9.    {
  10.      printf("Enter an integer value: ");
  11.      scanf("%d", &input);
  12.      answer = cube(input);
  13.      /* Note: %ld is the conversion specifier for */
  14.      /* a long integer */
  15.      printf("\n\nThe cube of %ld is %ld.", input, answer);
  16.   }
  17.  
  18.   long cube(long x)
  19.   {
  20.      long x_cubed;
  21.  
  22.      x_cubed = x * x * x;
  23.      return x_cubed;
  24.   }
  25.