CHAPTER 3
AN INTRODUCTION TO FUNCTIONS

[IMAGE: An Quarter-Size Version of The Joy of C Front Cover]
This chapter finishes our tutorial introduction to C. We focus on user-defined functions, showing how we can define simple functions and use them to improve upon our earlier interest rate programs. Along the way, we cover function definitions, function calls, function prototypes, and function return values. We also introduce the process of compiling programs that contain functions defined in multiple source files. Finally, we demonstrate how using functions leads to more readable and maintainable programs, and we discuss how to test the functions we've written. By this chapter's end, you should feel comfortable constructing programs from functions you write yourself.

Jump to: [Previous Chapter | Next Chapter]


  1. WRITING OUR OWN FUNCTIONS
  2. SEPARATE COMPILATION
  3. SOME ADDITIONAL FEATURES OF FUNCTIONS

Function�� ���� �� ���

��1) ������ ���� ����� �ϴ� ���α׷� (intrate7.c)

��2) 2���� source file��� ������ C ���α׷� (irmain.c, irfuncs.c)

���α׷��� ���


�ǽ�)

  1. n, m �� ������ �Է��Ͽ� n���� m������ ������ ���� ���ϴ� ���α׷� �ۼ� (0 < n, m < 1000).
  2. ���� ������ ȭ�鿡 ����϶�.
    *
   ***
  *****
 *******
*********



Assignment #3 (�Ⱓ: 1����)

���α׷� 1) Combination�� ����ϴ� ���α׷��� �ۼ��϶�.
Combination function C(n, k) = n! / [k! * (n - k)!]

���� ���:

Enter number of objects in the set (n)? 5
Enter number to be chosen (k)? 3
C(5, 3) = 10

���α׷� 2) �� �ǽ� 2�� �������� �غ��� ũ�⸦ ������ Ȧ���� �Է¹޾� �׸��� ���α׷����� �����Ͽ� �ۼ��϶�.


[ Table Of Contents | Previous Chapter | Next Chapter]