1.1 Statements and the structure of a program

주홍영·2022년 3월 10일
0

Learncpp.com

목록 보기
13/199

https://www.learncpp.com/cpp-tutorial/statements-and-the-structure-of-a-program/

Chapter introduction

이번 챕터에서는 c++ program의 필수적인 주제에 대해서 다룬다
꽤나 여러개의 주제가 있으므로 얕게 다루고
이 챕터에서 목표는 c++프로그램이 어떻게ㅔ constructed 되어있는지 이해하는 것이다

다음 챕터들에서는 주요한 주제들에 대해서 디테일하게 다룬다
We’ll also introduce new concepts that build on top of these.
우리는 또한 이것들을 기반으로 하는 새로운 개념을 소개할 것입니다.

Statements

프로그램은 일련의 statement로 이루어져있다
statement는 일종의 instruction이다

statement는 c++ program에서 가장 흔한 instruction의 타입이다.

대부분의 statement는 semicolon으로 끝난다
c++과 같은 high-level language의 경우 하나의 statement는 많은 기계어의 instruction으Dissecting 로 compile 된다.

Functions and the main function

statement는 일반적으로 function으로 묶여진다
function은 순차적으로 statement를 실행하도록 되어진 statement 모음집이다
(순차적으로, from top to bottom)

Rule

모든 c++ 프로그램은 반드시 main이라는 특별한 함수를 가지고 있다. 프로그램이 실행되면 main의 statement가 순차적으로 실행된다

프로그램은 일반적으로 main함수의 마지막 statement가 실행되면 종료된다

preprocessor

전처리기는 컴파일러가 수행되기 전에
미리정의된 심볼들을 바꾸러 주는 역할을 합니다.
예시)
#include <stdio.h>
#define one 1
#define two 2
#define sum(a,b) (a+b)

Syntax and syntax errors

The rules that govern how sentences are constructed in a language is called syntax.
이러한 언어의 구성 규칙을 깨면 syntax error가 발생한다
ex) ; 세미클론 누락

Quiz

Q1 What is a statement?

A statement is an instruction in a computer program that tells the computer to perform an action.

Q2 What is a function?

A function is a collection of statements that executes sequentially.

Q3 What is the name of the function that all programs must have?

main

Q4 When a program is run, where does execution start?

Execution starts with the first statement inside the main function.

Q5 What symbol are statements in C++ often ended with?

The semicolon (;)

Q6 What is a syntax error?

A syntax error is a compiler error that occurs at compile-time when your program violates the grammar rules of the C++ language.

Q7 What is the C++ Standard Library?

A library file is a collection of precompiled code that has been “packaged up” for reuse in other programs. The C++ Standard Library is a library that ships with C++. It contains additional functionality to use in your programs.

**** 단어장

dissect : 해부하다
Dissecting : 해부

profile
청룡동거주민

0개의 댓글