Thread: calculate the factorial and display in two column.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Quote Originally Posted by Elkvis View Post
    Consider also, the fact that 20! is far too big for an int, on most platforms.
    Oh shoot! It looks like it just barely fits in a long int or whatever the 8 byte int type is. Man, it's pretty easy to see how large factorials can become!

    This might also be a good lesson in how and why to use typedefs for this kind of thing.

    But as for displaying, it might be easiest to just store all 20 factorial calculations in an array. Then you can simply iterate it and print as you go. Including the weird `std::cout << arr[0] << " " << arr[10] << "\n";` to get 2 columns.
    Last edited by MutantJohn; 10-27-2016 at 12:28 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 12-07-2013, 03:51 PM
  2. Replies: 3
    Last Post: 12-06-2013, 07:15 PM
  3. Replies: 13
    Last Post: 05-02-2012, 04:17 PM
  4. calculate column-wise sum of a matrix in C
    By Raymond2010 in forum C Programming
    Replies: 4
    Last Post: 06-21-2011, 11:21 PM
  5. Tab control: how to calculate a tab display area???
    By SundayDeveloper in forum Windows Programming
    Replies: 4
    Last Post: 09-06-2007, 03:19 PM

Tags for this Thread