answersLogoWhite

0


Best Answer

The following function will return the GCD or LCM of two arguments (x and y) depending on the value of the fct argument (GCD or LCM).

enum FUNC {GCD, LCM};

int gcd_or_lcm(FUNC fct, int x, int y) {

int result = 0;

switch (fct) {

case (GCD): result = gcd (x, y); break;

case (LCM): result = lcm (x, y); break;

}

return result;

}

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

This question is not a question. You are supposed to do your homework yourself.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a C program to find the GCD and LCM of two numbers using a switch statement?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program large number and small number among n numbers by using If statement?

12


How do you break a loop in a switch case statement?

using break; statement


How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


Write a program By using if else statement to read a number and check whether it is positive or negative?

write a c++program by using if statement to read a number and check whether it is positive or negative


Discount program using java switch case?

This is not a question.


Program to count the number of numbers in an array using 8085 microprocessor?

A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.


Write a FORTRAN program using if statement to calculate the smallest of three numbers xyz?

N = x If y < N then N = Y If z < N then N = z Print N


Write a program that will graph using for loop?

A = 5do{statement;A = A + 1;} while (A < 10)


How do you write a program using the gotoxy statement and print function to display letters of the alphabet on the computer screen?

There is no gotoxy statement in C.


How can you accept sum and print numbers without creating variables?

It is very easy. The program begins here..... /*Program to sum and print numbers without creating variables*/ #include&lt;stdio.h&gt; main() { clrscr(); printf("%d+%d=%d",5,2,5+2); getch(); } /*Program ends here*/ Now just by changing the numbers in the "printf" statement we can add, subtract, multiply and divide the numbers without using variables. Hence the problem is solved..........


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.