1 / 30

Function

Function. KJS. Function. Function ?. Function. 두둥 .. 우리는 이미 함수를 사용하고 있었다는 ... main( .. ) printf ( .. ) scanf ( .. ) ……. Function. 준비물 ( 인자 ). 함수의 내용. 함수 이름. 작업결과 ( 반환값 …). Function. printf ( .. ) 함수 함수이름 : printf 인자 ( parameter ): 형식문자열 ( format )

joanne
Télécharger la présentation

Function

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Function KJS

  2. Function • Function ?

  3. Function • 두둥.. 우리는 이미 함수를 사용하고 있었다는... • main( .. ) • printf( .. ) • scanf( .. ) • ……

  4. Function 준비물(인자) 함수의 내용 함수 이름 작업결과 (반환값…)

  5. Function • printf( .. ) 함수 • 함수이름 : printf • 인자 ( parameter ): 형식문자열 ( format ) • 함수의 내용 : 출력하고 싶은 내용을 출력 • 반환 값 ( return value ): 출력된 전체 문자의 개수. 출력에 실패하면 음수가 출력된다.

  6. Function • main( .. ) 함수 • 함수이름 : main • 인자 ( parameter ): command line parameter • 함수의내용 : 실행할 code • 반환 값 ( return value ) : 기본적으로 프로그램의 정상적인 종료를 나타낼 수 있음. • 전체프로그램에서 하나는 반드시 존재하는 함수.

  7. Function • Example

  8. Function • Example

  9. Function • Example

  10. Function • Example

  11. Function • Parameter (형식인자)& Argument (실인자)

  12. Function • return • 함수로 부터 결과값을 돌려줌 – 어디로? • 함수의 강제 종료

  13. Function • Function의 사용 • 선언과 정의를 한번에

  14. Function • Function의 사용 • 선언과 정의를 따로

  15. Function • Function의 사용

  16. 전역변수 & 지역변수

  17. * C언어의 Memory구조 • Data • 프로그램의 시작에 할당 • 프로그램 종료에 소멸 • Heap • 프로그래머의 필요에 의해 할당 및 소멸이 이루어짐 • Stack • 지역변수와 매개변수 할당 • 함수 호출 완료 시 소멸

  18. main

  19. func1 main

  20. func2 main

  21. 전역변수 & 지역변수 • * static, auto, extern, register ?

  22. Call by Value & Call by Address

  23. Call by Value • 실인수의 값이 형식인수로 전달 Memory N = 5 별개의 메모리 공간 N = 5 main callByValue

  24. Call by Address • 실인수의번지값을 형식인수로 전달 ( 실인수를직접 참조) Memory N = 5 pN = &N main N을 가리키고있다 callByAddress

  25. Call by Value & Call by Address

  26. Call by Value & Call by Address

  27. Recursive call ; 재귀호출 • 자기가 자기 자신을 호출 • ex) Factorial

  28. HW • 삼각형, 다이아몬드를 함수를 이용하여 작성 • 재귀함수를 이용하여 삼각형 출력시키기

More Related