answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

void main()

{

int x,y,z,i;

clrscr();

printf("Enter Two Numbers = ");

scanf("d%d",&x,&y);

for(i=1;i<=x*y*z;i++)

{

if(i%x==0&&i%y==0)

{

printf("LCM is %d\n",i);

break;

}

}

getch();

}

User Avatar

Wiki User

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

Wiki User

7y ago

#include<stdio.h>

#include<math.h>

long gcd (long a, long b) {

long temp;

while (a != 0) {

temp = a;

a = b % a;

b = temp;

}

return abs (b);

}

long lcm (long a, long b) {

if (a==0 b==0) return 0;

return a / gcd (a, b) * b;

}

int main (void) {

long a, b;

printf ("Enter two integers:\n");

scanf ("%d%d", &a, &b);

printf ("gcd(%d, %d) = %d\n", a, b, gcd (a, b));

printf ("lcm(%d, %d) = %d\n", a, b, lcm (a, b));

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

no

This answer is:
User Avatar

Add your answer:

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

Write a program to compute the sum of first ten integer numbers in PHP?

$n = 10*(1+10)/2;


Write a program to subtract integer y from integer x?

x -=y;


How do you find sum of 100 numbers using fortran programme?

The following is for F95 and later (due to the use of intrinsic SUM ): My assumptions: -Your numbers are integers -Your numbers are stored in an array -The numbers you are describing are 0-100 program findSum !I assumed integer, replace this with your data type integer, dimension(100) :: numbers integer :: sumOfNumbers !We populate an array with our numbers !Replace this with your numbers do i=1,(size(numbers)+1) numbers = i end do !We find the sum of those numbers sumOfNumbers = sum(numbers) !We write out the sum to prompt write(*,*) 'Sum is: ', sumOfNumbers end program findSum


How do you write a program to find out the square and cube of first ten natural numbers in gw basic?

First you will need to have some basic programming knowledge. You can use this to help make the program that is needed.


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


How do you write prime numbers?

In the same way as you would write any integer.


How would you write Visual Basic Code to declare an Integer variable called intNumber?

Dim intNumber As Integer


Write a program to input two numbers and interchange there value using the third variable Give anawers in Basic method?

Public Sub Swap() dim inta as integer dim intb as integer dim intc as integer inta=4 intb=5 intb=inta intc=intb inta=intc End Sub


How do you write a program in Basic to display all the even numbers up to 100?

In visual basic: Module Module1 Sub Main() Dim Inst As Integer For Inst = 0 To 100 Step 2 Console.WriteLine(Inst) Next End Sub End Module


Write a program that counts by powers of 2 in visual basic?

TextBox1.Multiline = TrueDim amount As Integer = 200For index As Integer = 1 To amountTextBox1.Text = TextBox1.Text & " " & index ^ 2 & ","Next~Note: make sure you have a textbox called textbox 1


How do you write a standard basic program?

That really depends on what sort of program you are trying to build, what do you want the program to do?


Write a program in Lex to eliminate white space and collect numbers as a token?

write a lex program to delete space from the program