&& (and) , || (or)

Program 2014. 4. 2. 17:57


& (and) 조건을 다 만족할때
|  (or)    한개의 조건이라도 만족할때

<< 1. --------------------------------------------------

#include <iostream>
using namespace std;

int main(){

  int i = 4 ;

 if (i == 4 && i == 5)
   cout << " && (and)일 경우" << endl;
 if (i == 4 || i == 5)
 
  cout <<  " || (or)일 경우" << endl;;
 
 return 0;
}
----------------------------------------------
조건 한개라도 만족하므로
|| (or)
결과값

: || (or)일 경우


<< 2.1 ---------------------------------------

#include <iostream>
using namespace std;

int main(){

  int i = 4 ,j=5;

 if (i == 4 && j == 5)
   cout << " && (and)일 경우" << endl;
 if (i == 4 || j == 5)
 
  cout <<  " || (or)일 경우" << endl;;
 
 return 0;
}

----------------------------------------------
조건 두개다 만족하므로
&& (and)
조건 한개라도 만족하므로 || (or)
결과값
: && (and)일 경우
  || (or)일 경우

<< 2.3 ---------------------------------------

#include <iostream>
using namespace std;

int main(){

  int i = 4 ,j=6;

 if (i == 4 && j == 5)
   cout << " && (and)일 경우" << endl;
 if (i == 4 || j == 5)
 
  cout <<  " || (or)일 경우" << endl;;
 
 return 0;
}
----------------------------------------------
조건 한개라도 만족하므로 || (or)
결과값
: 
|| (or)일 경우

Posted by 행복한 시간들
,