answersLogoWhite

0


Best Answer

#include<stdio.h>

int main(){

int n1,n2;

printf("\nEnter two numbers:");

scanf("%d %d",&n1,&n2);

while(n1!=n2){

if(n1>=n2-1)

n1=n1-n2;

else

n2=n2-n1;

}

printf("\nGCD=%d",n1);

return 0;

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Find LCM and HCF of two given number by using for loop in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you sum a number's all digit using for loop?

Using for loop we can find sum of digits of a number. Inside the loop just perform Logic Expression 1) rem=num%10. {To find the unit place no. using remainder functon} 2) sum = sum+rem {to find the addition ie output} 3) num=num/10 {to eliminate the added digit} Just repeat these steps in the loop.


What is a C programming to calculate the sum of 1-2-3-4-5 and so on using while loop a for loop and a do while loop?

#include using std::cout;using std::endl;int main(){int number(1);cout number;//using loop forint sum(0);for(int i(1); i


To find biggest of four numbers using if else loop?

largest number a,b,c,d


Find factorial at given number using do while loop?

Actually, a for loop is more appropriate in this case. With while, it would be something like the following pseudocode - adapt to your favorite programming language:function factorial(n)result = 1factor = 1while factor


C program find magic number less than 1000?

#define int main (void){/*Algorithm*/1. First Initialize the number that is Random no2. Using while loop if the person got it, then the loop stop if not the loop continues.}return(0);


A loop control variable that is incremented a specific number of times is known as?

A loop control variable is widly known as a "counter".


C program to find square of number using do while loop?

class Abc { public static void main(String[] args) { System.out.println("Hello World!"); } }


How do you find the 12th prime number using c?

To keep it simple: Write a main loop that goes through all the numbers, starting with 2, and incrementing one at a time. Determine whether each number is a prime number. If it is, increment a counter. To determine whether each number is a prime number, either use an inner loop, or a separate function. Test divisibility of the number "n" by every number from 2 to n-1. If you find a factor, then it is not a prime number. Note that you can test divisibility by using the "%" operator. For example: if (number % factor == 0) // number is divisible by factor else // it isn't


How do you calculate loop length?

the multiplication of the number of iterations with the number of statements in that loop is equal to loop length.


Write a program using while loop?

//program to find the factorial value f any number using while loop #include&lt;stdio.h&gt; void main() { int i,n,fact=1; printf("Enter the number\n"); scanf("%d",&amp;n); i=n; while (i&gt;=1) { fact=fact*i; i--; } printf("The factorial value=%d",fact); } the above is a program for calculating tha factorial value of any number which is entered by the user


Flow chart using for loop?

There's a nice for Loop at the link below.


Write a PLSQL code to print a multiplication table where the input is given by the user in Oracle?

Declare num number(10):=&amp;num; a number(10); counter number:=1; begin for i in 1..10 LOOP a:=num*counter; DBMs_output.put_line(a); Counter:=counter+1; end loop; end;