예제 내용
define 정의 방법 변수에서 Overflow/Underflow에 관한 예제 const 상수 선언 방법 상수의 특징 |
#include<stdio.h>
#define PI 3.141592 //PI=3.141592
int sum_cnt = 1; //Global Var
int main(void)
{
int cntNum = 0; //camel case
int my_total = 0; //snake case
int cntTotal = 0;
short overF,underF,nonOverF,nonUnderF;
cntNum = 10;
my_total = 20;
cntTotal = 30;
cntNum = 40;
sum_cnt = 50;
printf("sumCount \t= %d\ncountNum \t= %d\nmy_Toal \t= %d\ncountTotal \t= %d\n", sum_cnt, cntNum, my_total, cntTotal);
nonOverF = 32767; //short 양수 최대값
overF = nonOverF + 1; //short 양수 최대값+1 이면 Overflow
nonUnderF = -32768; //short 음수 최소값
underF = nonUnderF - 1; //short 음수 최소값-1 이면 underflow
printf("MaxShort \t= %d\nMaxShort+1\t= %d\nMINShort \t= %d\nMINShort-1\t= %d\n", nonOverF, overF, nonUnderF, underF);
const int MAX = 200;
printf("#define PI\t= %f\n",PI);
printf("const\t\t= %d\n", MAX);
printf("const\t\t= %d\n", MAX + 100);
return 0;
}
Output
'C\C++' 카테고리의 다른 글
형변환 예제 (0) | 2022.02.09 |
---|---|
type_문제 (0) | 2022.02.09 |
while문 예제 (0) | 2022.02.08 |
Switch~case 연습 (0) | 2022.02.07 |
Visual Studio _ C언어 프로젝트 작성 (0) | 2022.02.03 |