Multiplication of the two numbers without using * operator in C#

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #3618

    Multiplication of the two numbers without using * operator in C#.
    try this code:

     
    static int Multiply(int a, int b)
            {
                if (a == 0 || b == 0)
                {
                    return 0;
    
                }
                else
                {
                    int sum = 0;
                    for (int i = 0; i < b; i++)
                    {
                        sum += a;
                    }
                    return sum;
                }
            }
    
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.