카테고리

asm (27) bootloader_x86_grub (1) C (92) compile (11) config (76) CPP (13) CSS (1) debugging (7) gimp (1) Go (1) html (1) Java (1) JavaScript (1) kernel (19) LibreOffice (3) Linux system progamming (21) MFC (1) opencv (4) OpenGL (1) PHP (1) Python (4) qemu (29) shell (3) socket (7) troubleshooting (2) ubuntu18.04 (2) windows (1)

2018/12/08

C 논리 연산, logic operator

#include <stdio.h>

int logic_call(){
printf("\n");

// Missed less then 10 days work AND
// Has over 30,000 OR
// Signed up more then 30 new customers

int bobMissedDays = 8, bobTotalSales = 24000,
    bobNewCust = 32;

if(bobMissedDays < 10 && bobTotalSales > 30000 || bobNewCust > 30){
printf("Bob Gets a Raise\n\n");
}else{
printf("Bob Doesn't Get a Raise\n\n");
}
}

int ternary_operator(){
printf("\n");

int custAge = 38;

char* legalAge = (custAge > 21) ? "true" : "false";

printf("Is the customer of legal age? %s\n\n", legalAge);

int numOfProducts = 10;
printf("I bought %s products\n\n",
(numOfProducts > 1) ? "many" : "one");

}

void main(void){
// && - and
// !! - or
// ! - not !0 = 1, !1 = 0;

int custAge = 38;

if(custAge > 21 && custAge < 35)
printf("They are weclome\n\n");
else printf("They are not welcome\n\n");

printf("! turns a true into false : %d\n\n", !1);

logic_call();

ternary_operator();
}

댓글 없음:

댓글 쓰기