w3resource

C#: Calculate the full product of two 32-bit numbers

C# Sharp Math: Exercise-9 with Solution

Write a C# Sharp program to calculate the full product of two 32-bit numbers.

Sample Solution:

C# Sharp Code:

using System;
using System.Text;
namespace exercises {
  class Program {
    public static void Main() {
      int int1 = Int32.MaxValue;
      int int2 = Int32.MaxValue;
      long longResult;
      longResult = Math.BigMul(int1, int2);
      Console.WriteLine("Calculate the product of two Int32 values:");
      Console.WriteLine("{0} * {1} = {2}", int1, int2, longResult);
    }
  }
}

Sample Output:

Calculate the product of two Int32 values:
2147483647 * 2147483647 = 4611686014132420609

Flowchart:

Flowchart: C# Sharp Exercises - Calculate the full product of two 32-bit numbers.

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: Write a C# Sharp program to calculate the quotient of two 32-bit signed integers and also returns the remainder in an output parameter.
Next: Write a C# Sharp program to reverse the digits of a given signed 32-bit integer.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.