1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OLga [1]
3 years ago
12

Implementations in c++ programming when finding lcm and gcd in c++​

Computers and Technology
1 answer:
vazorg [7]3 years ago
7 0

Answer:

#include<iostream>

using namespace std;

int lcm(int m, int n) {

  int a;

  a = (m > n) ? m: n;

  while (true) {

     if (a % m == 0 && a % n == 0)

        return a;

        ++a;

  }

}

int gcd(int m, int n) {

  int r = 0, a, b;

  a = (m > n) ? m : n;

  b = (m < n) ? m : n;

  r = b;

  while (a % b != 0) {

     r = a % b;

     a = b;

     b = r;

  }

  return r;

}

int main(int argc, char **argv) {

  cout << "Enter the two numbers: ";

  int m, n;

  cin >> m >> n;

  cout << "The LCM of two numbers is: " << lcm(m, n) << endl;

  cout << "The GCD of two numbers is: " << gcd(m, n) << endl;  

  return 0;

}

Explanation:

You might be interested in
What is the danger in judging someone according to his or her social networking profile
AfilCa [17]
They could find you and throw hands.
8 0
3 years ago
How do I change my keyboard's debounce time?
Zanzabum

in the control board type:

HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response\BounceTime

3 0
3 years ago
Read 2 more answers
Use the drop-down menus to complete statements about back-up data files.
vlada-n [284]

Answer:

the third one trust me

Explanation:

5 0
3 years ago
Read 2 more answers
the function must find the substrings of s that start with a vowel and end with a consonant, then print the alphabetically first
PolarNik [594]

According to the parameters given in the questions above, the alphabetically lowest and highest substrings that start with a vowel and end with a Consonant is given below.

<h3>What is the determined substrings described above?</h3>

The determined substring is given by the following:

def findSubstrings(s):

   sub_strings_list=[]    #the required substrings list

   vowels=['a','e','i','o','u']    #vowels list

   for i in range(0,len(s)):    

       for j in range(i+1,len(s)+1):

           sub_string=s[i:j]    #slicing the original string into substring

           #checking whether the substring starts with a vowel and ends with a consonant

           if(sub_string[0] in vowels and sub_string[-1] not in vowels):    

               if(sub_string not in sub_strings_list):    #checking if the substring is already in the list

                   sub_strings_list.append(sub_string)    #if all conditions are satisfied adding the substring to the list

   sub_strings_list.sort()    #sorting the list alphabetically

   print(sub_strings_list[0])    #printing the first substring in the list

   print(sub_strings_list[-1])    #printing the last substring in the list

s=input()

findSubstrings(s)

Learn more about substrings:
brainly.com/question/21306076
#SPJ4

Full Question:

Consider a string, s — An alphabetically-ordered sequence Of Of s would be {"a", "ab•, "abc • , "bcu, If the sequence is reduced to only those substrings that start with a vowel and end with a consonant, the result is Cab", •abc"}. The alphabetically first element in this reduced list is •ab", and the alphabetically last element is "abc'. As a reminder:

Vowels: a, e, i, o, and u.

Consonants: b, c, d, f, g, h, i, k, l, m, n, p, q, r, s, t, v, w, x, y, and z.

For a given string, determine the alphabetically lowest and highest substrings that start with a vowel and end with a Consonant.

7 0
2 years ago
Deborah believes that people of other nationalities are inferior to her. She treats them with disdain and does not miss an oppor
belka [17]
I recommend asking another category, not sure which one but computers and technology is not a good start. Keep looking and good luck!
3 0
3 years ago
Other questions:
  • According to your course, two benefits of a cloud-based system are_ and_
    12·1 answer
  • The scope of a variable declared within a for() loop is:
    6·1 answer
  • The media is a phase that people often use to refer to:
    6·1 answer
  • Software that instructs the computer how to run applications and controls the display/keyboard is know as the
    8·1 answer
  • You can sort a large array of integers that are in the range 1 to 100 by using an array count of 100 items to count the number o
    9·1 answer
  • Say you find a module in a package that does a lot of awesomely useful things, but the name of it is module_that_does_many_aweso
    12·1 answer
  • Hoda wants to create a new presentation in PowerPoint with existing graphics and designs. What is the easiest and fastest way fo
    14·1 answer
  • landon starts his computer and gets message, hard drive is not found. He was watching a movie the previous night, what might the
    6·1 answer
  • NEED HELP ASAP!!!
    10·1 answer
  • Help me code game plz just comment below for more info
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!