Home > Articles > Programming > C/C++

  • Print
  • + Share This
This chapter is from the book

Summary

This hour covered how to work with simple kinds of information in C++ such as integers, floating-point values, and characters. Variables are used to store values that can change as a program runs. Constants store values that stay the same—in other words, they are not variable.

The biggest challenge when using variables is choosing the proper type. If you're working with signed integers that might go higher than 65,000, you should store them in a long rather than a short. If they might go higher than 2.1 billion, they're too big for a long. If a numeric value contains decimal values, it must be either float or double, the two floating-point types in the C++ language.

Another thing to keep in mind when working with variables is the number of bytes they occupy, which can vary on different systems. The sizeof() function provided by the compiler returns the number of bytes any variable type requires.

  • + Share This
  • 🔖 Save To Your Account