A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C++ program to multiply two integers without using multiplication, division, bitwise operators, and loops
Q:

Write a C++ program to multiply two integers without using multiplication, division, bitwise operators, and loops

0

Write a C++ program to multiply two integers without using multiplication, division, bitwise operators, and loops

Sample Input: 8, 9
Sample Output: 72

Sample Input: -11, 19
Sample Output: -209

Sample Output:

72
-209

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
  
using namespace std; 
int multiply_two_nums(int x, int y) 
{ 
    if(y == 0) 
    return 0; 
  
    if(y > 0 ) 
    return (x + multiply_two_nums(x, y-1 )); 
  
    if(y < 0 ) 
    return - multiply_two_nums(x, -y); 
}

int main() 
{ 
    cout << multiply_two_nums(8, 9) << endl; 
    cout << multiply_two_nums(-11, 19) << endl ;
    return 0; 
} 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now