I have a larger assignment due this week that I cannot get a

I have a larger assignment due this week that I cannot get a grasp on coding. I understand the least common multiple but am unsure what syntax and when to use it when coding in c++

Ask the user for two numbers, use a loop to find the least common multiple. If the program does not find one by 100, stop looking. Display each number between 1 and 100 looking for the LCM.

Solution

#include <iostream>
int main()
{
  
int number1, number2, max;

std::cout << \"Enter two numbers: \";
std::cin >> number1 >> number2;
  
max = (number1 > number2) ? number1 : number2;

do
{
   if(max>100)
   {
      std::cout<<\"LeastCommanMultiple is Greater than 100\"<<std::endl;
      std::cout<<\"The number You Are Entered are:\"<<std::endl<<number1<<\"\\t\"<<number2<<std::endl;
       break;
   }
else if (max % number1 == 0 && max % number2 == 0)
{
std::cout << \"LeastCommanMultiple is: = \" << max;
break;
}
else
++max;
} while (true);
  
  
return 0;
}

OutPut is :

1)- Enter two numbers: 12 18
LeastCommanMultiple is: = 36
--------------------------------

2)Enter two numbers: 19 21
LeastCommanMultiple is Greater Than 100

The number you Are Entered Are :

19 21

--------------------------------

I have a larger assignment due this week that I cannot get a grasp on coding. I understand the least common multiple but am unsure what syntax and when to use i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site