Welcome :Guest

Congratulations!!!

 Home >> Code Snippets >> Visual Studio >> Post New Resource

# Maximum of the Product of Two Numbers

Posted By:papsantony       Posted Date: August 13, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com

Maximum of the Product of Two Numbers

Find the maximum value of the product of two positive numbers whose sum is 100.

`using System;public class Program{    static int Main()    {        // Find the maximum value of the product of         // two positive numbers whose sum is 100.        for(int i = 1; i < 100; i++)            Console.WriteLine("{0,2} + {1,2} = {2,2}\t{3,2} * {4,2} = {5,4}",                              i, 100 - i, i + (100 - i),                              i, 100 - i, i * (100 - i));        Console.WriteLine();        return 0;    }}`

This would produce:

` 1 + 99 = 100    1 * 99 =   99 2 + 98 = 100    2 * 98 =  196 3 + 97 = 100    3 * 97 =  291 4 + 96 = 100    4 * 96 =  384 5 + 95 = 100    5 * 95 =  475 6 + 94 = 100    6 * 94 =  564 7 + 93 = 100    7 * 93 =  651 8 + 92 = 100    8 * 92 =  736 9 + 91 = 100    9 * 91 =  81910 + 90 = 100   10 * 90 =  90011 + 89 = 100   11 * 89 =  97912 + 88 = 100   12 * 88 = 105613 + 87 = 100   13 * 87 = 113114 + 86 = 100   14 * 86 = 120415 + 85 = 100   15 * 85 = 127516 + 84 = 100   16 * 84 = 134417 + 83 = 100   17 * 83 = 141118 + 82 = 100   18 * 82 = 147619 + 81 = 100   19 * 81 = 153920 + 80 = 100   20 * 80 = 160021 + 79 = 100   21 * 79 = 165922 + 78 = 100   22 * 78 = 171623 + 77 = 100   23 * 77 = 177124 + 76 = 100   24 * 76 = 182425 + 75 = 100   25 * 75 = 187526 + 74 = 100   26 * 74 = 192427 + 73 = 100   27 * 73 = 197128 + 72 = 100   28 * 72 = 201629 + 71 = 100   29 * 71 = 205930 + 70 = 100   30 * 70 = 210031 + 69 = 100   31 * 69 = 213932 + 68 = 100   32 * 68 = 217633 + 67 = 100   33 * 67 = 221134 + 66 = 100   34 * 66 = 224435 + 65 = 100   35 * 65 = 227536 + 64 = 100   36 * 64 = 230437 + 63 = 100   37 * 63 = 233138 + 62 = 100   38 * 62 = 235639 + 61 = 100   39 * 61 = 237940 + 60 = 100   40 * 60 = 240041 + 59 = 100   41 * 59 = 241942 + 58 = 100   42 * 58 = 243643 + 57 = 100   43 * 57 = 245144 + 56 = 100   44 * 56 = 246445 + 55 = 100   45 * 55 = 247546 + 54 = 100   46 * 54 = 248447 + 53 = 100   47 * 53 = 249148 + 52 = 100   48 * 52 = 249649 + 51 = 100   49 * 51 = 249950 + 50 = 100   50 * 50 = 250051 + 49 = 100   51 * 49 = 249952 + 48 = 100   52 * 48 = 249653 + 47 = 100   53 * 47 = 249154 + 46 = 100   54 * 46 = 248455 + 45 = 100   55 * 45 = 247556 + 44 = 100   56 * 44 = 246457 + 43 = 100   57 * 43 = 245158 + 42 = 100   58 * 42 = 243659 + 41 = 100   59 * 41 = 241960 + 40 = 100   60 * 40 = 240061 + 39 = 100   61 * 39 = 237962 + 38 = 100   62 * 38 = 235663 + 37 = 100   63 * 37 = 233164 + 36 = 100   64 * 36 = 230465 + 35 = 100   65 * 35 = 227566 + 34 = 100   66 * 34 = 224467 + 33 = 100   67 * 33 = 221168 + 32 = 100   68 * 32 = 217669 + 31 = 100   69 * 31 = 213970 + 30 = 100   70 * 30 = 210071 + 29 = 100   71 * 29 = 205972 + 28 = 100   72 * 28 = 201673 + 27 = 100   73 * 27 = 197174 + 26 = 100   74 * 26 = 192475 + 25 = 100   75 * 25 = 187576 + 24 = 100   76 * 24 = 182477 + 23 = 100   77 * 23 = 177178 + 22 = 100   78 * 22 = 171679 + 21 = 100   79 * 21 = 165980 + 20 = 100   80 * 20 = 160081 + 19 = 100   81 * 19 = 153982 + 18 = 100   82 * 18 = 147683 + 17 = 100   83 * 17 = 141184 + 16 = 100   84 * 16 = 134485 + 15 = 100   85 * 15 = 127586 + 14 = 100   86 * 14 = 120487 + 13 = 100   87 * 13 = 113188 + 12 = 100   88 * 12 = 105689 + 11 = 100   89 * 11 =  97990 + 10 = 100   90 * 10 =  90091 +  9 = 100   91 *  9 =  81992 +  8 = 100   92 *  8 =  73693 +  7 = 100   93 *  7 =  65194 +  6 = 100   94 *  6 =  56495 +  5 = 100   95 *  5 =  47596 +  4 = 100   96 *  4 =  38497 +  3 = 100   97 *  3 =  29198 +  2 = 100   98 *  2 =  19699 +  1 = 100   99 *  1 =   99Press any key to continue . . .`

Responses

No response found. Be the first to respond this post

Post Comment