1 / 10

실습예제

실습예제. 실습 예제 모음. [ 기본예제 1-1] 산술 연산자의 사용. 다음의 실행 결과가 나오도록 코딩하시오. [ 기본예제 1-1] 산술 연산자의 사용. 01 #include<iostream.h> 02 03 int main(int argc, char* argv[]) 04 { 05 06 int x = 1; 07 int y = 2; 08 09 int result1 = x + y; 10 int result2 = x - y; 11 int result3 = x * y;

echo-jensen
Download Presentation

실습예제

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 실습예제 실습 예제 모음

  2. [기본예제 1-1] 산술 연산자의 사용 • 다음의 실행 결과가 나오도록 코딩하시오

  3. [기본예제 1-1] 산술 연산자의 사용 • 01 #include<iostream.h> • 02 • 03 int main(int argc, char* argv[]) • 04 { • 05 • 06 int x = 1; • 07 int y = 2; • 08 • 09 int result1 = x + y; • 10 int result2 = x - y; • 11 int result3 = x * y; • 12 int result4 = x / y; • 13 int result5 = x % y; • 14 • 15 cout << "x + y = " << result1 << "\n"; • 16 cout << "x - y = " << result2 << "\n"; • 17 cout << "x * y = " << result3 << "\n"; • 18 cout << "x / y = " << result4 << "\n"; • 19 cout << "x % y = " << result5 << "\n"; • 20 • 21 return 0; • 22 } 변수를 선언한다. 사칙 연산을 한다. 결과를 출력한다.

  4. [기본예제 1-2] 관계 연산자의 사용 • 다음의 실행 결과가 나오도록 코딩하시오

  5. [기본예제 1-2] 관계 연산자의 사용 • 01 #include<iostream.h> • 02 • 03 int main(int argc, char* argv[]) • 04 { • 05 • 06 int x = 1; • 07 int y = 2; • 08 • 09 bool r1 = x == y; • 10 bool r2 = x > y; • 11 bool r3 = x < y; • 12 bool r4 = x >= y; • 13 bool r5 = x <= y; • 14 bool r6 = x != y; • 15 • 16 cout << x << " == " << y << " : " << r1 << "\n"; • 17 cout << x << " > " << y << " : " << r2 << "\n"; • 18 cout << x << " < " << y << " : " << r3 << "\n"; • 19 cout << x << " >= " << y << " : " << r4 << "\n"; • 20 cout << x << " <= " << y << " : " << r5 << "\n"; • 21 cout << x << " != " << y << " : " << r6 << "\n"; • 22 • 23 return 0; • 24 } 변수를 선언한다. 관계 연산을 수행 한다. 결과를 출력한다.

  6. [기본예제 1-3] 비트 연산자의 사용 • 다음의 실행 결과가 나오도록 코딩하시오

  7. [기본예제 1-3] 비트 연산자의 사용 • 01 #include <iostream.h> • 02 • 03 int main(int argc, char* argv[]) • 04 { • 05 • 06 short int x = 1; • 07 short int y = 2; • 08 • 09 short int r1 = x & y; • 10 short int r2 = x | y; • 11 short int r3 = ~x; • 12 short int r4 = x ^ y; • 13 • 14 cout.setf(ios::hex); • 15 cout << x << " & " << y << " = " << r1 << "\n"; • 16 cout << x << " | " << y << " = " << r2 << "\n"; • 17 cout << " ~ " << x << " = " << r3 << "\n"; • 18 cout << x << " ^ " << y << " = " << r4 << "\n"; • 19 • 20 return 0; • 21 } 변수를 선언한다. 비트 연산을 수행 한다. 결과를 출력한다.

  8. [기본예제 1-4] 기타 연산자의 사용 • 다음의 실행 결과가 나오도록 코딩하시오

  9. [기본예제 1-4] 기타 연산자의 사용 • 01 #include<iostream.h> • 02 • 03 int main(int argc, char* argv[]) • 04 { • 05 • 06 int x=1; • 07 • 08 int r1 = x++; • 09 int r2 = ++x; • 10 • 11 cout << "r1 = x++ : " << r1 << "\n"; • 12 cout << "r2 = ++x : " << r2 << "\n"; • 13 cout << "x = " << x << "\n"; • 14 • 15 return 0; • 16 } 변수를 선언한다. 연산을 수행 한다. 결과를 출력한다.

  10. Thank You ! www.themegallery.com

More Related