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

Home Forums General Programming C# Multiplication of the two numbers without using * operator in C#

This topic contains 0 replies, has 1 voice, and was last updated by  Hirendra Sisodiya 5 years, 9 months ago.

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.