SlideShare a Scribd company logo
Variables and
Selection Statement
Presented by Junyoung Jung
Club MARO
Dept. of Electronic and Radio Engineering
Kyung Hee Univ.
ch2.
Content
1.
Variables and Types
2.
Operators
3.
Selection statement
4.
Practice
5.
Assignments
0.
Last class Review
Content
3
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
. . .
Computer
Content
4
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
// iostream 이라는 header 파일(;cpp파일 앞에 위치)을 포함
#include <iostream>
// sdt 라는 namespace(; 소속, ‘준영이의’ 외모, ‘동재의’ 외모) 사용
using namespace std;
int main()
{
// Hello World 문자열 모니터에 출력
cout << “Hello World” << endl;
return 0;
}
Content
5
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
변수란 무엇인가?
먼저 컴퓨터 구조를 알아보자
Content
6
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
CPU Memory
I/O I/O
. . .
0
4
8
100
104
108
Processing
Content
7
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
데이터가 저장될 임의의 공간
메모리에 변수가
저장될 공간을 할당하는 것
# 변수
# 변수 선언
Content
8
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
- true, new, int 등 미리 지정되어 있는 키워드 불가
- 변수 이름 첫 글자는 숫자 불가
- 변수 이름에 특수문자 포함 불가
- 변수 이름 사이의 공백 불가
# 변수 선언 주의사항
…
int main() {
int powerButton, keyButton;
double m_value;
char in_signature;
…
return 0;
}
Content
9
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
가독성이 좋은 이름을 사용하자!!
…
int main() {
int num;
// num이 어떤 값을 가지는지 알지 못하기 때문에 error
cout << num << endl;
return 0;
}
Content
10
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
변수의 초기화를 잊지 말자!!
Content
11
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
int 정수형 변수 4byte
double 실수형 변수 8byte
char 문자형 변수 1byte
# 주요 변수
Content
12
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
#include <iostream>
using namespace std;
int main() {
// 정수형 변수 a선언, a에 100 할당
int a;
a = 100;
cout << a << endl;
return 0;
}
Content
13
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
변수가 있다면
상수도 있을까?
Content
14
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
#include <iostream>
using namespace std;
const double pi = 3.141592;
int main() {
…
const int a = 100;
return 0;
}
Content
15
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
지역변수(local value),
전역변수(global value)
차이 조사하기!!!
Assignment 1)
Content
16
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
연산자(Operator)?
data를 information으로
사용할 수 있게끔 해주는 역할
- 준영 생각
Content
17
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
# 산술 연산자
# 대입 연산자
# 논리 연산자
+, -, *, /, %
a = a+1;
a += 1;
a++;
a && b;
a || b;
# 관계 연산자 a == b;
a != b;
Content
18
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
#include <iostream>
using namespace std;
int main() {
/*
1. 정수형 변수 num과 실수형 변수 result을 선언
2. result 을 10이라 할당
3. num 을 키보드 입력
4. num과 result의 합, 차, 곱,
나눗셈의 몫과 나머지를 모니터 출력
*/
}
#Practice 산술 연산자
Content
19
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
…
int main() {
int a = 100;
a++;
cout << “a++결과 : ” << a << endl;
a -= 21;
cout << “a -= 21 결과 : ” << a << endl;
a = a*2;
cout << “a= a*2 결과 : ” << a << endl;
return 0;
}
#Practice 대입 연산자
Content
20
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
조건문(Selection statement)?
특정조건을 만족할 때,
해당 문장을 수행
- if-else 문
- switch 문
Content
21
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
if-else ①
if(조건문) {
조건문 만족시 실행할 문장
}
Content
22
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
if-else ②
if(조건문) {
조건문 만족시 실행할 문장
}
else {
조건문에 해당하지 않는 사항
}
Content
23
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
if-else ③
if(조건1) {
조건문 만족시 실행할 문장
}
else if (조건2) {
조건문에 해당하지 않는 사항
}
else if (조건3) {
}
…
else {
}
Content
24
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
…
int main() {
int a, b;
cin >> a >> b;
if(a == b) {
cout << a << “와 ” << b << “가 같습니다.” << endl;
}
else if(a > b) {
cout << a << “가 ” << b << “보다 큽니다.” << endl;
}
else {
cout << a << “가 ” << b << “보다 작습니다.” << endl;
}
return 0;
}
#Practice if-else
Content
25
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
Assignment 2 를
같이 만들어 보아요 !!
Content
26
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
지역변수(local value),
전역변수(global value)
차이 조사하기!!!
Assignment 1)
Content
27
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes 1. 정수형 변수 선언
2. cin을 통해 두 변수에 값 할당
3. if-else문을 이용하여
사칙연산 프로그램 만들기
Assignment 2)
Pracctice 를 본인의 스타일로 다시 해보기
Content
28
0.
Last classReview
2.
Operators
3.
Selectionstatement
4.
Practice
5.
Assignments
1.
VariablesandTypes
Assignment 2의
내용을 설계하기
Assignment 3)
Thank you

More Related Content

PDF
W14 chap13
웅식 전
 
PPTX
NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서
tcaesvk
 
PDF
6 function
웅식 전
 
PDF
Javascript - Function
wonmin lee
 
PDF
6 swift 고급함수
Changwon National University
 
PDF
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
 
PDF
코딩인카페 C&JAVA 기초과정 C프로그래밍(2)
유익아카데미
 
PPTX
PPL: Composing Tasks
용준 김
 
W14 chap13
웅식 전
 
NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서
tcaesvk
 
6 function
웅식 전
 
Javascript - Function
wonmin lee
 
6 swift 고급함수
Changwon National University
 
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(2)
유익아카데미
 
PPL: Composing Tasks
용준 김
 

What's hot (20)

PDF
2013 C++ Study For Students #1
Chris Ohk
 
PDF
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
Chris Ohk
 
PDF
C++ Concurrency in Action 9-2 Interrupting threads
Seok-joon Yun
 
PDF
5 swift 기초함수
Changwon National University
 
PPTX
포트폴리오에서 사용한 모던 C++
KWANGIL KIM
 
PPT
Refactoring - Chapter 8.2
Ji Ung Lee
 
PDF
C++17 Key Features Summary - Ver 2
Chris Ohk
 
PDF
코딩인카페 C&JAVA 기초과정 C프로그래밍(1)
유익아카데미
 
PDF
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
유익아카데미
 
PDF
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Seok-joon Yun
 
PDF
[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준
Seok-joon Yun
 
PPTX
[devil's camp] - 알고리즘 대회와 STL (박인서)
NAVER D2
 
PDF
C++20 Key Features Summary
Chris Ohk
 
PPTX
자바스크립트 함수
유진 변
 
PDF
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
Seok-joon Yun
 
KEY
Cleancode ch14-successive refinement
Kyungryul KIM
 
PDF
[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...
Seok-joon Yun
 
PPTX
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
DongMin Choi
 
PDF
[Swift] Generics
Bill Kim
 
PPTX
Java8 람다
Jong Woo Rhee
 
2013 C++ Study For Students #1
Chris Ohk
 
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
Chris Ohk
 
C++ Concurrency in Action 9-2 Interrupting threads
Seok-joon Yun
 
5 swift 기초함수
Changwon National University
 
포트폴리오에서 사용한 모던 C++
KWANGIL KIM
 
Refactoring - Chapter 8.2
Ji Ung Lee
 
C++17 Key Features Summary - Ver 2
Chris Ohk
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(1)
유익아카데미
 
코딩인카페 C&JAVA 기초과정 C프로그래밍(3)
유익아카데미
 
Effective Modern C++ MVA item 18 Use std::unique_ptr for exclusive-ownership ...
Seok-joon Yun
 
[C++ Korea] Effective Modern C++ MVA item 8 Prefer nullptr to 0 and null +윤석준
Seok-joon Yun
 
[devil's camp] - 알고리즘 대회와 STL (박인서)
NAVER D2
 
C++20 Key Features Summary
Chris Ohk
 
자바스크립트 함수
유진 변
 
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to type...
Seok-joon Yun
 
Cleancode ch14-successive refinement
Kyungryul KIM
 
[C++ korea] effective modern c++ study item 7 distinguish between () and {} w...
Seok-joon Yun
 
[C++ Korea 2nd Seminar] Ranges for The Cpp Standard Library
DongMin Choi
 
[Swift] Generics
Bill Kim
 
Java8 람다
Jong Woo Rhee
 
Ad

Viewers also liked (9)

PDF
[C++]6 function2
Junyoung Jung
 
PDF
[C++]1 ready tobeprogrammer
Junyoung Jung
 
PDF
[C++]4 review
Junyoung Jung
 
PDF
[2016 K-global 스마트디바이스톤] inSpot
Junyoung Jung
 
PDF
[대학생 연합 해커톤 UNITHON 3RD] Mingginyu_ppt
Junyoung Jung
 
PDF
[C++]5 function
Junyoung Jung
 
PDF
[Maybee] inSpot
Junyoung Jung
 
PDF
[C++]3 loop statement
Junyoung Jung
 
PDF
16 학술제 마무리 자료
Junyoung Jung
 
[C++]6 function2
Junyoung Jung
 
[C++]1 ready tobeprogrammer
Junyoung Jung
 
[C++]4 review
Junyoung Jung
 
[2016 K-global 스마트디바이스톤] inSpot
Junyoung Jung
 
[대학생 연합 해커톤 UNITHON 3RD] Mingginyu_ppt
Junyoung Jung
 
[C++]5 function
Junyoung Jung
 
[Maybee] inSpot
Junyoung Jung
 
[C++]3 loop statement
Junyoung Jung
 
16 학술제 마무리 자료
Junyoung Jung
 
Ad

Similar to [C++]2 variables andselectionstatement (20)

PPTX
C review
Young Wook Kim
 
PDF
게임프로그래밍입문 3주차
Yeonah Ki
 
PDF
02장 자료형과 연산자
웅식 전
 
PDF
HI-ARC PS 101
Jae-yeol Lee
 
PDF
03장 조건문반복문네임스페이스
웅식 전
 
PPTX
[170327 1주차]C언어 A반
arundine
 
PDF
3주차 스터디
Seungwee  Choi
 
PPT
C수업자료
koominsu
 
PPT
C수업자료
koominsu
 
PPTX
Basic study 4회차
Seonmun Choi
 
PDF
2015 Kitel C 언어 강좌3
ssuseraf62e91
 
PDF
7 mid term summary
웅식 전
 
PPTX
03장 조건문, 반복문, 네임스페이스
유석 남
 
PDF
3 2. if statement
웅식 전
 
PPTX
파이썬 기초
Yong Joon Moon
 
PDF
2015 Kitel C 언어 강좌1
ssuseraf62e91
 
PPTX
컴퓨터개론05
Edward Hwang
 
PDF
2주차 스터디
Seungwee  Choi
 
PDF
C언어 연산자에 대해 간과한 것
jaypi Ko
 
PDF
C 언어 스터디 02 - 제어문, 반복문, 함수
Yu Yongwoo
 
C review
Young Wook Kim
 
게임프로그래밍입문 3주차
Yeonah Ki
 
02장 자료형과 연산자
웅식 전
 
HI-ARC PS 101
Jae-yeol Lee
 
03장 조건문반복문네임스페이스
웅식 전
 
[170327 1주차]C언어 A반
arundine
 
3주차 스터디
Seungwee  Choi
 
C수업자료
koominsu
 
C수업자료
koominsu
 
Basic study 4회차
Seonmun Choi
 
2015 Kitel C 언어 강좌3
ssuseraf62e91
 
7 mid term summary
웅식 전
 
03장 조건문, 반복문, 네임스페이스
유석 남
 
3 2. if statement
웅식 전
 
파이썬 기초
Yong Joon Moon
 
2015 Kitel C 언어 강좌1
ssuseraf62e91
 
컴퓨터개론05
Edward Hwang
 
2주차 스터디
Seungwee  Choi
 
C언어 연산자에 대해 간과한 것
jaypi Ko
 
C 언어 스터디 02 - 제어문, 반복문, 함수
Yu Yongwoo
 

More from Junyoung Jung (16)

PDF
[KCC oral] 정준영
Junyoung Jung
 
PDF
전자석을 이용한 타자 연습기
Junyoung Jung
 
PDF
[2018 평창올림픽 기념 SW 공모전] Nolza 보고서
Junyoung Jung
 
PDF
[2018 평창올림픽 기념 SW 공모전] Nolza - Activity curation service
Junyoung Jung
 
PDF
SCC (Security Control Center)
Junyoung Jung
 
PDF
Google File System
Junyoung Jung
 
PDF
sauber92's Potfolio (ver.2012~2017)
Junyoung Jung
 
PDF
Electron을 사용해서 Arduino 제어하기
Junyoung Jung
 
PDF
[UNITHON 5TH] KOK - 프로귀찮러를 위한 지출관리 서비스
Junyoung Jung
 
PDF
[우아주, Etc] 정준영 - 페이시스템
Junyoung Jung
 
PDF
[우아주, 7월] 정준영
Junyoung Jung
 
PDF
[team608] 전자석을 이용한 타자연습기
Junyoung Jung
 
PDF
[Kcc poster] 정준영
Junyoung Jung
 
PDF
[Graduation Project] 전자석을 이용한 타자 연습기
Junyoung Jung
 
PDF
[KCC poster]정준영
Junyoung Jung
 
PDF
[2015전자과공모전] ppt
Junyoung Jung
 
[KCC oral] 정준영
Junyoung Jung
 
전자석을 이용한 타자 연습기
Junyoung Jung
 
[2018 평창올림픽 기념 SW 공모전] Nolza 보고서
Junyoung Jung
 
[2018 평창올림픽 기념 SW 공모전] Nolza - Activity curation service
Junyoung Jung
 
SCC (Security Control Center)
Junyoung Jung
 
Google File System
Junyoung Jung
 
sauber92's Potfolio (ver.2012~2017)
Junyoung Jung
 
Electron을 사용해서 Arduino 제어하기
Junyoung Jung
 
[UNITHON 5TH] KOK - 프로귀찮러를 위한 지출관리 서비스
Junyoung Jung
 
[우아주, Etc] 정준영 - 페이시스템
Junyoung Jung
 
[우아주, 7월] 정준영
Junyoung Jung
 
[team608] 전자석을 이용한 타자연습기
Junyoung Jung
 
[Kcc poster] 정준영
Junyoung Jung
 
[Graduation Project] 전자석을 이용한 타자 연습기
Junyoung Jung
 
[KCC poster]정준영
Junyoung Jung
 
[2015전자과공모전] ppt
Junyoung Jung
 

[C++]2 variables andselectionstatement