c (24) 썸네일형 리스트형 C arrays #2 정적 지역 배열 및 자동 지역 배열- 정적 배열 : 배열의 크기가 프로그램이 컴파일될 때 고정되는 배열 - 정적 배열은 프로그램 시작 시 한 번 초기화, 함수가 다시 호출될 때 이전 상태를 유지한다. ( 함수가 여러 번 호출되더라도 배열은 한 번만 초기화 한다.)#include void staticArrayInit(void) { static int arr[5]; // 정적 지역 배열 선언 for (int i = 0; i - 자동 지역 배열 : 함수가 호출될 때마다 초기화된다. 이전 호출의 상태를 유지하지 않는다.#include void autoArrayInit(void) { int arr[5] = {0}; // 자동 지역 배열 선언 및 초기화 for (int i = 0; i /.. function exercises #4 5.32 (Guess the Number)Write a C program that plays the game of “guess the number” as follows: Your program chooses the number to be guessed by selecting an integer at random in the range 1 to 1000. The program then types:I have a number between 1 and 1000.Can you guess my number?Please type your first guess.The player then types a first guess. The program responds with one of the following:Exce.. function exercises #3 5.23 (Time in Seconds)Write a function that takes the time as three integer arguments (for hours, minutes, and seconds) and returns the number of seconds since the last time the clock "struck 12." Use this function to calculate the amount of time in seconds between two times, both of which are within one 12-hour cycle of the clock. 5.23 (초 단위 시간)시간을 세 개의 정수 인수(시간, 분, 초)로 입력받아 마지막으로 시계가 "12시를 친" .. function exercises #2 5.17 (Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether they are the sides of a right-angled triangle. The function should take three integer arguments and return 1 (true) if the arguments comprise a right-angled triangle, and 0 (false) otherwise. Use this function in a program that inputs a series of sets of integers. 5.17 (직각 삼각형의 변)세 개의 0이 아닌.. functions Exercises 5.1 Answer each of the following: 다음 각 문항에 답하시오: a) _________ are used to modularize programs. a) _________는 프로그램을 모듈화하는 데 사용됩니다.답 : functions . 함수는 프로그램 모듈화에 사용된다.b) A function is invoked with a(n) _________. b) 함수는 _________로 호출됩니다.답 : function call . 함수 호출c) A variable known only within the function in which it's defined is called a(n) _________. c) 정의된 함수 내에서만 알려진 변수를 _________라고 합니다.답 : loc.. functions #1 함수 - C언어에서는 함수를 사용하여 프로그램을 모듈화- 표준 라이브러리 함수 : printf, scanf, pow 함수 - 수학 라이브러리 함수 : # include 를 헤더에 포함함수설명예제sqrt(x)x의 제곱근sqrt(900.0) is 30.0sqrt(9.0) is 3.0cbrt(x)x의 세제곱근cbrt(27.0) is 3.0cbrt(-8.0) is -2.0exp(x)지수 함수 e^xexp(1.0) is 2.718282exp(2.0) is 7.389056log(x)x의 자연 로그 natural logarithm of x (base e)log (2.718282) is 1.0log (7.389056) is 2.0log10(x)x의 로그logarithm of x (base 10)log (1.0) is.. C arrays #1 배열 - 배열 : 동일한 유형의 관련 데이터 항목으 로 구성된 데이터 구조, 동일한 유형의 연속적 메모리 위치- 배열, 구조체 : 프로그램 실행 중에 크기가 동일하게 유지되는 '정적' entities- 모든 배열의 첫 번째 요소는 0번째 요소(즉, 위치 번호가 0인 요소) - 배열 대괄호 [ ] 안의 위치 번호를 '인덱스 index' 또는 'subscript' 라고 함. 인덱스는 정수 또는 정수 표현식c[2] = 1000;c[2] = lvalue // 할당의 왼쪽에 사용, 1000 = rvalue // 할당의 오른쪽에 사용c[a+b] +=2; - 배열에 사용되는 대괄호 [ ] 는 실제로 '연산자' 로 간주. '동일한 우선 순위' 를 갖는다.연산자결합성유형[ ] ( ) ++(postfix, 후위) -.. C Pointer #1 포인터의 정의 포인터는 값이 메모리 주소인 변수변수 이름은 값을 직접 참조하고 포인터는 값을 간접적으로 참조한다. 포인터를 통해 값을 참조하는 것을 간접 참조라고 한다. 포인터의 선언 모든 변수와 마찬가지로 포인터는 사용하기 전에 정의해야 한다.int *countPtr ; 변수 countPtr가 int * 유형(즉, 정수에 대한 포인터)임을 지정 (오른쪽에서 왼쪽으로 읽음)“countPtr는 int에 대한 포인터” 또는 “countPtr는 int 유형의 객체”포인터의 초기화 와 포인터 연산자 NULL 값을 가진 포인터는 아무것도 가리키지 않는다.NULL : 헤더(및 와 같은 다른 여러 헤더)에 정의된 기호 상수 포인터를 0으로 초기화하는 것은 포인터를 NULL로 초기화하는 것과 같지만, NUL L이.. 이전 1 2 3 다음