Computer Science, asked by samsung5736, 11 months ago

10. You can multiply two number ‘m’ and ‘n’ by repeatedly addition method. For example 5*3=15 can be performed by adding 5 three times 5+5+5=15. Similarly, successive subtraction of two numbers produces ‘Quotient’ and ‘Reminder’ when a number ‘a’ is divided by ‘b’ (a>b). For example 5/2= Quotient =2 and Remainder = 1 Follow the steps shown below: Process Result Counter 5-2 3 1 3-2 1 2 Write a program to accept two numbers. Perform multiplication and division of the numbers as per the process shown above by using switch case statement.

Answers

Answered by ArianneHester
1

Answer:

the program for the same is given below:-

#include <iostream>

using namespace std;

int main() {

   int a, b, ctr = 0, prod = 0, result, small;

   cin >> a >> b;

   char op = '*';

   switch(op)

   {

        case  '*': while(ctr != b) { prod += a; ctr++; } cout << prod << '\n';

        case '/':

              (a>b)? result = a, small = b: result = b, small = a;

               if(small > result/2) cout << 1 << '\n';

               else {

                     while(small > (result - small)) {

                              small = result - small;

                              result = small + result - small;

                      }

                }

                break;

   }

   

   return 0;

}

Reference:

for more reference refer the following:

for gcd of 2 numbers

https://brainly.in/question/16268185

Similar questions