개념 :
1. 논리연산이란 크다, 작다, 같다 의 연산 결과 입니다.
2. 정수형값 형태로 1과 혹은 0만이 존재 합니다.
3. 참인경우 1, 거짓인 경우0 이 됩니다.
소스 코드
#include<stdio.h>
int main (void)
{
int nValue_1 = 12;
int nValue_2 = -3;
int nBooleanLogic_1 = 0;
int nBooleanLogic_2 = 0;
int nBooleanLogic_3 = 0;
int nBooleanLogic_4 = 0;
int nBooleanLogic_5 = 0;
nBooleanLogic_1 = nValue_1 > nValue_2; // 변수1은 변수2 보다 크다
nBooleanLogic_2 = nValue_1 < nValue_2; // 변수1은 변수2 보다 작다
nBooleanLogic_3 = nValue_1 >= nValue_2;// 변수1은 변수2 보다 크거나 같다
nBooleanLogic_4 = nValue_1 <= nValue_2;// 변수1은 변수2 보다 작거나 같다
nBooleanLogic_5 = nValue_1 == nValue_2;// 변수1은 변수2 와 같다
printf("변수1: %d \n변수2: %d \n",nValue_1, nValue_2);
if(nBooleanLogic_1)
{
printf("변수1은 변수2 보다 크다 , 참\n");
}
else
{
printf("변수1은 변수2 보다 크다 , 거짓\n");
}
if(nBooleanLogic_2)
{
printf("변수1은 변수2 보다 작다 , 참\n");
}
else
{
printf("변수1은 변수2 보다 작다 , 거짓\n");
}
if(nBooleanLogic_3)
{
printf("변수1은 변수2 보다 크거나 같다 , 참\n");
}
else
{
printf("변수1은 변수2 보다 크거나 같다 , 거짓\n");
}
if(nBooleanLogic_4)
{
printf("변수1은 변수2 보다 작거나 같다 , 참\n");
}
else
{
printf("변수1은 변수2 보다 작거나 같다 , 거짓\n");
}
if(nBooleanLogic_5)
{
printf("변수1은 변수2 보다 같다 , 참\n");
}
else
{
printf("변수1은 변수2 보다 같다 , 거짓\n");
}
return 0;
}
결과
'Programing - C > C Basic grammar ' 카테고리의 다른 글
016 문자형 상수( const char ) (0) | 2016.09.21 |
---|---|
015 문자열형 변수 이해하기( char* ) (0) | 2016.09.21 |
013 실수형 변수( float, double ) (0) | 2016.09.21 |
바이너리와 2진수 (binary) (0) | 2016.09.20 |
012 정수형 변수( int ) (0) | 2016.09.20 |