Sunday, 15 March 2015

write a program on multiplication without using using multiplication sign

Leave a Comment
Code:

#include <iostream>
using namespace std;
int mult (int, int);


int main () {
  int x, y;
  cout << "Enter two natural numbers: ";
  cin >> x >> y;
  cout << x << " * " << y << " = " << mult(x,y) << endl;
  return(0);
}

int mult (int x, int y) {
  int result;
  result = 0;
  while (y != 0) {
    result = result + x;
   y = y - 1;
  }
  return(result);
}

Output


If You Enjoyed This, Take 5 Seconds To Share It

0 Questions: