Lesson 2: more simple program

Third program: surface and volume of the sphere

  • work with rational numbers
    • float datatype
    • arithmetic operators
    • comparison operator
      • do not confuse equality operator (==) and assignment (=)
    • limited range and accuracy
  • constants
    • value can be set only in definition declaration

Forth program: power function with natural exponent

  • statement while
  • required initialization of local variables
  • functions
  • function type and function parameters (so far only passing by value)
    • definition declaration (definition) and forward declaration (prototype)
  • splitting source code into several files
    • implementation files (.cpp file extension)
    • header files (.h extension)
      • usually contains function prototypes
      • preprocessor directive include
      • protection against multiple inclusion

Attachments

Poslední úprava stránky: 18.10.2022, 11:17
Powered by PmWiki