1. ¹è¿­ a¿¡ ÀÖ´Â ¼ö Áß¿¡¼­ °¡Àå Å« ¼ö¸¦ ã´Â ÇÁ·Î±×·¥ÀÌ´Ù. aÀÇ ¸Ç óÀ½ ¼ö¸¦ Àü¿ª º¯¼ö m¿¡ ÀúÀåÇÑ ÈÄ, aÀÇ ³ª¸ÓÁö ¿ø¼Òµé¿¡ ´ëÇؼ­ ÀÌ µéÀ» m°ú ºñ±³ÇÏ¿© ÀÌ°ÍÀÌ mº¸´Ù Å©¸é mÀ» ÀÌ °ªÀ¸·Î ¼öÁ¤ÇÏ´Â ¾Ë°í¸®ÁòÀ» Àû¿ëÇÑ´Ù. #include int m; main () { int a[] = {3, 1, 2, 7, 3, 9, 2}; m = a[0]; max(a, 6); printf ("Max is %d\n", m); } max (int a[], int n) { int i; for (i=n; i != 0; i--) if (a[i] > m) m = a[i]; } 2. m ¡Â nÀÇ Á¶°ÇÀ» ¸¸Á·ÇÏ´Â ÀÓÀÇÀÇ µÎ Á¤¼ö m°ú nÀÌ ÁÖ¾îÁ³À»¶§, mºÎÅÍ n»çÀÌÀÇ ¸ðµç Á¤¼öµéÀ» ´õÇÏ´Â ±â´ÉÀ» ÇÑ´Ù. #include /* sum all numbers from m to n */ main() { int m = 2; int n = 10; printf("result is %d\n", sum(m, n)); } int sum(int m, int n) { int k = 0; for ( ; m <= n; m++) k = k + m; return k; } 3. ÀÌ ÇÁ·Î±×·¥Àº ¹è¿­ aÀÇ ¸ðµç ¼öµéÀ» °öÇÏ´Â ±â´ÉÀ» ÇÑ´Ù. #include main () { int a[] = {1, 2, 3, 4}; printf ("Product is %d\n", product (a, 3)); /* largest index of a */ } int product(int a[], int n) { int k = 1; for ( ; n >= 0; n--) k = k * a[n]; return k; } 4. ÀÌ ÇÁ·Î±×·¥¿¡¼­´Â mºÎÅÍ n»çÀÌÀÇ ¼ö Áß¿¡¼­ ¦¼ö ÀÎ ¼öµéÀ» ÇÑ ÁÙ¿¡ 5°³¾¿ ÇÁ¸°Æ®ÇÏ´Â ±â´ÉÀ» ÇÑ´Ù. #include /* m¿¡¼­ n±îÁö ¦¼ö¸¦ ÇÑ ÁÙ¿¡ 5°³¾¿ ÇÁ¸°Æ®Çϱâ */ main() { int m = 2; int n = 180; printEven5(m, n, 1); /* initialize the count to 1 */ } void printEven5(int m, int n, int i) { for ( ; m <= n; m++) if (m%2 == 0) { printf("%d ", m); if (i % 5 == 0) printf("\n"); i = i +1; } } 5. ÀÌ ÇÁ·Î±×·¥Àº ½ºÆ®¸µ ÇüÅ·ΠÁÖ¾îÁø ¼öµéÀ» Á¤¼ö·Î º¯È¯ÇÏ´Â ÇÁ·Î±×·¥ÀÌ´Ù. ¿¹¸¦ µé¾î, ½ºÆ®¸µ "12345"¸¦ Á¤¼ö °ª 12345 °¡ µÇµµ·Ï º¯È¯ÇÑ´Ù. ÀÌ ¹®Á¦¿¡¼­´Â ¸ÕÀú ÇÔ¼ö s2nÀ» Loop ¹æ½ÄÀ¸·Î ÇÁ·Î±×·¡¹Ö ÇÑ ´ÙÀ½, ÀÌ¿Í °°Àº ±â´ÉÀ» ÇÏ´Â Àç±ÍÇÔ¼ö¸¦ Á¤ÀÇÇϵµ·Ï ÇÑ´Ù. #include main () { char a[] = "12345"; /* string of numbers */ printf ("The value is %d\n", s2n(a, 4)); /* index varies 0 to 4 */ } int s2n (char s[], int i) { /* conversion of a string to a number */ ... ... ... ... ... ÀÌ°÷¿¡ ÄÚµùÀ» ÇÏ¿© ÇÁ·Î±×·¥À» ¿Ï¼ºÇϽÿÀ. ... ... ... ... ... }