Самые популярные вопросы и ответы для интервью и онлайн-тесты
Образовательная платформа для подготовки к интервью, онлайн-тестов, учебных материалов и живой практики

Развивайте навыки с целевыми маршрутами обучения, пробными тестами и контентом для подготовки к интервью.

WithoutBook объединяет вопросы для интервью по предметам, онлайн-практику, учебные материалы и сравнительные руководства в одном удобном учебном пространстве.

Chapter 2

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

Learn the basic syntax of C programs, primitive data types, variable declarations, constants, formatting, and console input-output.

Inside this chapter

  1. Basic Syntax Rules
  2. Primitive Data Types
  3. Declaring Variables and Constants
  4. Formatted Output and Input
  5. Format Specifiers
  6. Real-World Usage Snapshot

Series navigation

Study the chapters in order for the clearest path from C basics to advanced memory, systems, debugging, and real-world development practice. Use the navigation at the bottom of each page to move smoothly through the full tutorial.

Tutorial Home

Chapter 2

Basic Syntax Rules

C is case-sensitive. Statements usually end with semicolons. Blocks are defined using braces. Variables must be declared before use. Unlike some higher-level languages, C expects the programmer to be precise about types and storage.

Chapter 2

Primitive Data Types

Type Typical Usage
intWhole numbers
charSingle character or small integer byte value
floatSingle-precision floating-point
doubleDouble-precision floating-point
longLarger integer range depending on platform

Type size can depend on platform and compiler, so students should focus first on meaning and usage, then later on exact memory-level implications.

Chapter 2

Declaring Variables and Constants

int age = 21;
double price = 49.99;
char grade = 'A';
const int DAYS_IN_WEEK = 7;

const expresses intent clearly and helps prevent accidental modification.

Chapter 2

Formatted Output and Input

#include <stdio.h>

int main(void) {
    int age;
    printf("Enter your age: ");
    scanf("%d", &age);
    printf("You entered: %d\n", age);
    return 0;
}

printf and scanf are fundamental, but beginners must be careful with format specifiers and addresses. The & operator in scanf is one of the first hints that C deals directly with memory addresses.

Chapter 2

Format Specifiers

  • %d for int
  • %f for float and double in printf
  • %c for char
  • %s for strings
  • %ld for long
Chapter 2

Real-World Usage Snapshot

Even experienced engineers working with advanced systems still rely on clear understanding of primitive types, input-output formatting, and type discipline. Bugs in these basics can lead to wrong calculations, crashes, or undefined behavior later.

Авторские права © 2026, WithoutBook.