가장 많이 묻는 면접 질문과 답변 & 온라인 테스트
면접 준비, 온라인 테스트, 튜토리얼, 라이브 연습을 위한 학습 플랫폼

집중 학습 경로, 모의고사, 면접 준비 콘텐츠로 실력을 키우세요.

WithoutBook은 주제별 면접 질문, 온라인 연습 테스트, 튜토리얼, 비교 가이드를 하나의 반응형 학습 공간으로 제공합니다.

Chapter 2

Syntax, Data Types, Variables, Input Output, and Operators

Learn the basic building blocks of C++ programs including variables, built-in types, expressions, console I/O, and operator behavior.

Inside this chapter

  1. Basic Syntax and Variables
  2. Common Built-In Types
  3. Console Input and Output
  4. Operators and Expressions
  5. Type Conversion
  6. Real-World Usage Snapshot

Series navigation

Study the chapters in order for the clearest path from C++ basics to modern ownership, templates, concurrency, performance, and production-ready engineering practices. Use the navigation at the bottom to move smoothly through the full series.

Tutorial Home

Chapter 2

Basic Syntax and Variables

#include <iostream>

int main() {
    int age = 21;
    double salary = 45000.50;
    char grade = 'A';
    bool active = true;

    std::cout << age << '\n';
}

C++ is strongly typed and case-sensitive. Choosing meaningful variable names and correct types is one of the first important habits students should build.

Chapter 2

Common Built-In Types

Type Typical Usage
intWhole numbers
doubleFloating-point values
charSingle character
boolTrue or false conditions
std::stringText data
Chapter 2

Console Input and Output

#include <iostream>
#include <string>

int main() {
    std::string name;
    std::cout << "Enter name: ";
    std::cin >> name;
    std::cout << "Hello, " << name << '\n';
}

std::cin and std::cout are beginner-friendly standard stream interfaces. Later, students should also understand stream states, buffering, and line-based input.

Chapter 2

Operators and Expressions

C++ supports arithmetic, relational, logical, assignment, bitwise, and increment-decrement operators. Understanding precedence and side effects is important for correctness and readability.

int a = 10;
int b = 3;
int sum = a + b;
bool bigger = a > b;
int remainder = a % b;
Chapter 2

Type Conversion

double result = static_cast<double>(5) / 2;

C++ allows both implicit and explicit conversions. Beginners should learn to use explicit casts carefully when intent matters, instead of depending blindly on automatic conversion.

Chapter 2

Real-World Usage Snapshot

Every larger C++ system still depends on clean handling of types, input-output, and expressions. Sloppy basics create harder bugs later in templates, containers, concurrency, and performance-critical logic.

Copyright © 2026, WithoutBook.