Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
컴퓨터공학실습 1
Part 1
Ch3. 변수란 무엇인가
2011-03-17
1
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
목차
변수의 정의와 선언 방법
변수 선언 시 유의할 점
변수의 시작 주소와 & 연산자
2
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수의 정의와 선언 방법
변수란 ?
◦
데이터를 저장하기 위한 임시 저장 공간 ( 메모리 공간 )
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수의 정의와 선언 방법
변수 선언 예 :
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수의 정의와 선언 방법
변수의 종류
◦
정수형 : char, short, int, long 형
◦
실수형 : float, double, long double 형
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수의 정의와 선언 방법
데이터란 ?
◦
변수에 저장되는 값
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수의 정의와 선언 방법
변수의 초기화
◦
변수 선언과 동시에 초기화를 하는 것이 좋음
7
초기화 하지 않은 변수 값
사용 시 의미 없는 값 출
력
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수의 정의와 선언 방법
변수에 저장된 값 변경
◦
변수 선언 후 변수에 저장된 값을 자유롭게 변경 가능
8
변수에 저장된 값 변경
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수 선언 시 유의할 점
변수 선언은 제일 앞쪽에 한다
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수 선언 시 유의할 점
변수의 이름은 의미 있게 짓는다
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수 선언 시 유의할 점
변수 이름 규칙에 따른다
◦
특수 문자 , 공백 문자 , 맨 처음 숫자 사용 불가
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수 선언 시 유의할 점
변수 이름 규칙에 따른다
◦
C 언어는 대소문자 구분
◦
키워드 사용 불가
ANSI C 표준 키워드
12
Intelligence Modeling Lab.
School of Information and Communication Engineering, Sungkyunkwan University
변수의 시작 주소와 & 연산자
변수의 시작 주소
◦
해당 변수가 저장된 메모리 상의 위치 ( 주소 )
◦
& 연산자로 접근 가능
13