✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Like C, C++ is designed to let programs get close to the hardware when necessary. The arithmetic types are defined to cater to the peculiarities of various kinds of hardware. Accordingly, the number of arithmetic types in C++ can be bewildering. Most programmers can [and should] ignore these complexities by restricting the types they use. A few rules of thumb can be useful in deciding which type to use:
unsigned type when you know that the values cannot be negative.int for integer arithmetic. short is usually too small and, in practice, long often has the same size as int. If your data values are larger than the minimum guaranteed size of an int, then use long long.char or bool in arithmetic expressions. Use them only to hold characters or truth values. Computations using char are especially problematic because char is signed on some machines and unsigned on others. If you need a tiny integer, explicitly specify either signed char or unsigned char.double for floating-point computations. float usually doesn't have enough precision, and the cost of double-precision calculations versus single-precision is negligible. In fact, on some machines, double-precision operations are faster than single. The precision offered by long double usually is unnecessary and often entails considerable run-time cost.Now, determine the value written to the standard output stream by the following code fragment:
unsigned sum {};
for (unsigned u = 5; u >= 0; --u) {
sum += u;
}
std::cout << sum;
Write if the code doesn't compile. Write if the loop in the code fragment doesn't terminate. Write if the code causes undefined behavior at run time. Otherwise, write the exact text written to the standard output stream.