Table Of Contents
Previous Section Next Section

Program 35: So You Want to Print a Million

I didn't know we could have commas in C++ constants. So why does the following program compile? What does it do?

  1 /************************************************
  2  * print the value on one million.              *
  3  ************************************************/
  4 #include <iostream>
  5
  6 int main()
  7 {
  8     // Variable to hold a million
  9     long int one_million;
 10
 11     // Set the variable
 12     one_million = 1,000,000;
 13
 14     std::cout <<
 15         "One million " << one_million <<
 16         std::endl;
 17     return (0);
 18 }

(Next Hint 55. Answer 44.)

Table Of Contents
Previous Section Next Section