1.2 C++ Program Essential Parts and Control Flow Statements

Cards (22)

  • Preprocessor Directives are lines starting with # and are instructions for the preprocessor, which processes code before compilation.
  • #include <header_file> incorporates code from header files such as iostream for input/output.
  • #define defines constants or macros.
  • Header Files are included using the #include directive and prevent code duplication and promote modularity.
  • Standard library header files are typically enclosed in angle brackets (< >), while user-defined and third-party header files are enclosed in double quotes (" ").
  • User-Defined Header Files are created by programmers to organize their code and share declarations across multiple source files.
  • User-Defined Header Files typically contain function prototypes, class definitions, and global variable declarations.
  • User-Defined Header Files are included using #include "header_name.h".
  • System Header Files are included using #include directives and contain declarations of functions, classes, and variables from external libraries.
  • Third-Party Library Header Files are included using #include directives and contain declarations of functions, classes, and variables from external libraries.
  • The Main Function is the entry point of every C++ program and execution begins here.
  • Variables are named containers for storing data values and must be declared with a data type (e.g., int age = 10;).
  • Data Types specify the kind of data a variable can hold (e.g., int, float, char, string).
  • Expressions are combinations of values, variables, operators, and function calls that produce a result.
  • Operators are symbols that perform operations on values and variables (e.g., +, -, *, /, =, >=).
  • Statements are instructions that perform actions and can include variable declarations, assignments, function calls, control flow statements, etc.
  • Control Flow Statements control the program's execution flow and examples include if statements, while loops, and for loops.
  • Functions are reusable blocks of code that perform specific tasks and can take input parameters and return values.
  • Comments are text ignored by the compiler, used for explaining code and can be single-line comments (//) or multi-line comments (/* comment */).
  • Header Files contain declarations of functions, classes, and variables from external libraries and are included using #include directives.
  • The Standard Template Library (STL) is a collection of containers, algorithms, and iterators for data manipulation and is part of the C++ standard library.
  • Input/Output refers to interaction with users and files and common objects include cin for standard input stream for reading from the keyboard and cout for standard output stream for printing to the console.